1873{
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1887 int d_fd;
1888 fd_set mask, fdmask;
1889 FD_ZERO(&fdmask);
1890 FD_ZERO(&mask);
1891 int max_fd=0;
1892
1893
1894 struct timeval wt;
1895 struct timeval *wt_ptr=&wt;
1897 if (timeout== -1)
1898 {
1900 }
1901 else
1902 {
1903 wt.tv_sec = timeout / 1000000;
1904 wt.tv_usec = timeout % 1000000;
1905 }
1906
1907
1912 char fdmaskempty;
1913
1914
1915
1916 for(
i=L->
nr;
i>=0;
i--)
1917 {
1919 {
1921 {
WerrorS(
"all elements must be of type link");
return -2;}
1924 {
WerrorS(
"all links must be open");
return -2;}
1925 if (((strcmp(
l->m->type,
"ssi")!=0) && (strcmp(
l->m->type,
"MPtcp")!=0))
1926 || ((strcmp(
l->mode,
"fork")!=0) && (strcmp(
l->mode,
"tcp")!=0)
1927 && (strcmp(
l->mode,
"launch")!=0) && (strcmp(
l->mode,
"connect")!=0)))
1928 {
1929 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1930 return -2;
1931 }
1932 if (strcmp(
l->m->type,
"ssi")==0)
1933 {
1937 {
1938 FD_SET(d_fd, &fdmask);
1939 if (d_fd > max_fd) max_fd=d_fd;
1940 }
1941 else
1943 }
1944 else
1945 {
1946 Werror(
"wrong link type >>%s<<",
l->m->type);
1947 return -2;
1948 }
1949 }
1950 }
1951 max_fd++;
1952
1953do_select:
1954
1955 FD_ZERO(&mask);
1956 for(
k = 0;
k < max_fd;
k++)
1957 {
1958 if(FD_ISSET(
k, &fdmask))
1959 {
1961 }
1962 }
1963
1964
1965 s = si_select(max_fd, &mask,
NULL,
NULL, wt_ptr);
1967 {
1968 WerrorS(
"error in select call");
1969 return -2;
1970 }
1972 {
1973 return 0;
1974 }
1975 else
1976 {
1978 while (
j<=max_fd) {
if (FD_ISSET(
j,&mask))
break;
j++; }
1979 for(
i=L->
nr;
i>=0;
i--)
1980 {
1982 {
1984 if (strcmp(
l->m->type,
"ssi")==0)
1985 {
1989 }
1990 else
1991 {
1992 Werror(
"wrong link type >>%s<<",
l->m->type);
1993 return -2;
1994 }
1995 }
1996 }
1997
1999 {
2000
2001
2002
2004
2005 if (c== -1)
2006 {
2008 fdmaskempty = 1;
2009 for(
k = 0;
k < max_fd;
k++)
2010 {
2011 if(FD_ISSET(
k, &fdmask))
2012 {
2013 fdmaskempty = 0;
2014 break;
2015 }
2016 }
2017 if(fdmaskempty)
2018 {
2019 return -1;
2020 }
2021 if(timeout != -1)
2022 {
2025 wt.tv_sec = timeout / 1000000;
2026 wt.tv_usec = (timeout % 1000000);
2027 }
2028 goto do_select;
2029 }
2030
2031 else if (isdigit(c))
2033 else if (c>' ')
2034 {
2035 Werror(
"unknown char in ssiLink(%d)",c);
2036 return -2;
2037 }
2038
2039 goto do_select;
2040 }
2041 }
2042}
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)