1827{
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1841 int d_fd;
1842 fd_set mask, fdmask;
1843 FD_ZERO(&fdmask);
1844 FD_ZERO(&mask);
1845 int max_fd=0;
1846
1847
1848 struct timeval wt;
1849 struct timeval *wt_ptr=&wt;
1851 if (timeout== -1)
1852 {
1854 }
1855 else
1856 {
1857 wt.tv_sec = timeout / 1000000;
1858 wt.tv_usec = timeout % 1000000;
1859 }
1860
1861
1866 char fdmaskempty;
1867
1868
1869
1870 for(
i=L->
nr;
i>=0;
i--)
1871 {
1873 {
1875 {
WerrorS(
"all elements must be of type link");
return -2;}
1878 {
WerrorS(
"all links must be open");
return -2;}
1879 if (((strcmp(
l->m->type,
"ssi")!=0) && (strcmp(
l->m->type,
"MPtcp")!=0))
1880 || ((strcmp(
l->mode,
"fork")!=0) && (strcmp(
l->mode,
"tcp")!=0)
1881 && (strcmp(
l->mode,
"launch")!=0) && (strcmp(
l->mode,
"connect")!=0)))
1882 {
1883 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1884 return -2;
1885 }
1886 if (strcmp(
l->m->type,
"ssi")==0)
1887 {
1891 {
1892 FD_SET(d_fd, &fdmask);
1893 if (d_fd > max_fd) max_fd=d_fd;
1894 }
1895 else
1897 }
1898 else
1899 {
1900 Werror(
"wrong link type >>%s<<",
l->m->type);
1901 return -2;
1902 }
1903 }
1904 }
1905 max_fd++;
1906
1907do_select:
1908
1909 FD_ZERO(&mask);
1910 for(
k = 0;
k < max_fd;
k++)
1911 {
1912 if(FD_ISSET(
k, &fdmask))
1913 {
1915 }
1916 }
1917
1918
1919 s = si_select(max_fd, &mask,
NULL,
NULL, wt_ptr);
1921 {
1922 WerrorS(
"error in select call");
1923 return -2;
1924 }
1926 {
1927 return 0;
1928 }
1929 else
1930 {
1932 while (
j<=max_fd) {
if (FD_ISSET(
j,&mask))
break;
j++; }
1933 for(
i=L->
nr;
i>=0;
i--)
1934 {
1936 {
1938 if (strcmp(
l->m->type,
"ssi")==0)
1939 {
1943 }
1944 else
1945 {
1946 Werror(
"wrong link type >>%s<<",
l->m->type);
1947 return -2;
1948 }
1949 }
1950 }
1951
1953 {
1954
1955
1956
1958
1959 if (c== -1)
1960 {
1962 fdmaskempty = 1;
1963 for(
k = 0;
k < max_fd;
k++)
1964 {
1965 if(FD_ISSET(
k, &fdmask))
1966 {
1967 fdmaskempty = 0;
1968 break;
1969 }
1970 }
1971 if(fdmaskempty)
1972 {
1973 return -1;
1974 }
1975 if(timeout != -1)
1976 {
1979 wt.tv_sec = timeout / 1000000;
1980 wt.tv_usec = (timeout % 1000000);
1981 }
1982 goto do_select;
1983 }
1984
1985 else if (isdigit(c))
1987 else if (c>' ')
1988 {
1989 Werror(
"unknown char in ssiLink(%d)",c);
1990 return -2;
1991 }
1992
1993 goto do_select;
1994 }
1995 }
1996}
static int si_max(const int a, const int b)
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
void s_ungetc(int c, s_buff F)