1889{
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1903 int d_fd;
1904 fd_set mask, fdmask;
1905 FD_ZERO(&fdmask);
1906 FD_ZERO(&mask);
1907 int max_fd=0;
1908
1909
1910 struct timeval wt;
1911 struct timeval *wt_ptr=&wt;
1913 if (timeout== -1)
1914 {
1916 }
1917 else
1918 {
1919 wt.tv_sec = timeout / 1000000;
1920 wt.tv_usec = timeout % 1000000;
1921 }
1922
1923
1928 char fdmaskempty;
1929
1930
1931
1932 for(
i=L->
nr;
i>=0;
i--)
1933 {
1935 {
1937 {
WerrorS(
"all elements must be of type link");
return -2;}
1940 {
WerrorS(
"all links must be open");
return -2;}
1941 if (((strcmp(
l->m->type,
"ssi")!=0) && (strcmp(
l->m->type,
"MPtcp")!=0))
1942 || ((strcmp(
l->mode,
"fork")!=0) && (strcmp(
l->mode,
"tcp")!=0)
1943 && (strcmp(
l->mode,
"launch")!=0) && (strcmp(
l->mode,
"connect")!=0)))
1944 {
1945 WerrorS(
"all links must be of type ssi:fork, ssi:tcp, ssi:connect");
1946 return -2;
1947 }
1948 if (strcmp(
l->m->type,
"ssi")==0)
1949 {
1953 {
1954 FD_SET(d_fd, &fdmask);
1955 if (d_fd > max_fd) max_fd=d_fd;
1956 }
1957 else
1959 }
1960 else
1961 {
1962 Werror(
"wrong link type >>%s<<",
l->m->type);
1963 return -2;
1964 }
1965 }
1966 }
1967 max_fd++;
1968
1969do_select:
1970
1971 FD_ZERO(&mask);
1972 for(
k = 0;
k < max_fd;
k++)
1973 {
1974 if(FD_ISSET(
k, &fdmask))
1975 {
1977 }
1978 }
1979
1980
1981 s = si_select(max_fd, &mask,
NULL,
NULL, wt_ptr);
1983 {
1984 WerrorS(
"error in select call");
1985 return -2;
1986 }
1988 {
1989 return 0;
1990 }
1991 else
1992 {
1994 while (
j<=max_fd) {
if (FD_ISSET(
j,&mask))
break;
j++; }
1995 for(
i=L->
nr;
i>=0;
i--)
1996 {
1998 {
2000 if (strcmp(
l->m->type,
"ssi")==0)
2001 {
2005 }
2006 else
2007 {
2008 Werror(
"wrong link type >>%s<<",
l->m->type);
2009 return -2;
2010 }
2011 }
2012 }
2013
2015 {
2016
2017
2018
2020
2021 if (c== -1)
2022 {
2024 fdmaskempty = 1;
2025 for(
k = 0;
k < max_fd;
k++)
2026 {
2027 if(FD_ISSET(
k, &fdmask))
2028 {
2029 fdmaskempty = 0;
2030 break;
2031 }
2032 }
2033 if(fdmaskempty)
2034 {
2035 return -1;
2036 }
2037 if(timeout != -1)
2038 {
2041 wt.tv_sec = timeout / 1000000;
2042 wt.tv_usec = (timeout % 1000000);
2043 }
2044 goto do_select;
2045 }
2046
2047 else if (isdigit(c))
2049 else if (c>' ')
2050 {
2051 Werror(
"unknown char in ssiLink(%d)",c);
2052 return -2;
2053 }
2054
2055 goto do_select;
2056 }
2057 }
2058}
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)