summaryrefslogtreecommitdiff
path: root/misc/team/patches/patch-d
blob: a01497f9f8d67e34824d343a92643e309a4346c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
*** Makefile.ORIG	Fri Dec 13 16:26:46 1996
--- Makefile	Sat Dec 14 11:01:06 1996
***************
*** 3,8 ****
  BINDIR=	${PREFIX}/bin
  MANDIR=	${PREFIX}/man
  
! CFLAGS+= -DHAVE_PARAM_H
  
  .include <bsd.prog.mk>
--- 3,8 ----
  BINDIR=	${PREFIX}/bin
  MANDIR=	${PREFIX}/man
  
! CFLAGS+= -DHAVE_PARAM_H -DHAVE_WAIT_H
  
  .include <bsd.prog.mk>
*** team.c.ORIG	Fri Dec 13 16:26:50 1996
--- team.c	Sun Dec 15 10:35:10 1996
***************
*** 84,89 ****
--- 84,92 ----
  #include <sys/file.h>
  #include <sys/stat.h>
  #include <fcntl.h>
+ #ifdef HAVE_WAIT_H
+ #include <sys/wait.h>
+ #endif
  
  #ifdef HAVE_PARAM_H
  #include <sys/param.h>
***************
*** 165,170 ****
--- 168,174 ----
  
  local bool		verbose = false;
  local bool		report = true;
+ local bool		guyhaderror = false;
  
  extern int		errno;
  local time_t		origin;
***************
*** 647,653 ****
    {
      mesg("team: guy pid %u: %s\n",guy->pid,errormsg);
      call GuySEND(guy,TokenABORT,FdERROR,0L);
!     exit(1);
      /*NOTREACHED*/
    }
  
--- 651,657 ----
    {
      mesg("team: guy pid %u: %s\n",guy->pid,errormsg);
      call GuySEND(guy,TokenABORT,FdERROR,0L);
!     exit(2);
      /*NOTREACHED*/
    }
  
***************
*** 807,812 ****
--- 811,819 ----
      {
        pid = getpid();
  
+       /* Set SIGPIPE handling back to the default in the guys */
+       signal(SIGPIPE, SIG_DFL);
+ 
        if (!FdClose(&last_downstream))
  	perror("cannot close inherited first link");
  
***************
*** 826,838 ****
      }
    }
  
!   if (!StreamSend(&last_downstream,TokenREAD,FdOPEN,0L))
    {
      perror("cannot send first READ token");
      return false;
    }
  
!   if (!StreamSend(&last_downstream,TokenWRITE,FdOPEN,0L))
    {
      perror("cannot send first WRITE token");
      return false;
--- 833,845 ----
      }
    }
  
!   if (!StreamSend(&last_downstream,TokenREAD,FdOPEN,0L) && errno != EPIPE)
    {
      perror("cannot send first READ token");
      return false;
    }
  
!   if (!StreamSend(&last_downstream,TokenWRITE,FdOPEN,0L) && errno != EPIPE)
    {
      perror("cannot send first WRITE token");
      return false;
***************
*** 874,879 ****
--- 881,894 ----
  
      --team->active;
  
+ #ifdef WIFEXITED
+     /* If a guy had an error, its exit status is 2.  Also catch a killed guy */
+     if ((WIFEXITED(status) && WEXITSTATUS(status) == 2) ||
+ 	(WIFSIGNALED(status) && WTERMSIG(status) != SIGPIPE)) {
+       guyhaderror = true;
+     }
+ #endif
+ 
      if (status != 0   && team->active != 0)
        return false;
    }
***************
*** 1042,1047 ****
--- 1057,1067 ----
  
    origin = time((time_t *) 0);
  
+   /*
+    * Ignore SIGPIPE in the parent as it affects the exit status reporting.
+    */
+   signal(SIGPIPE, SIG_IGN);
+ 
    if (!TeamStart(&team,bufsize,isize,osize))
    {
      mesg("team: cannot start the team\n");
***************
*** 1062,1067 ****
--- 1082,1093 ----
    if (!TeamClose(&team))
    {
      mesg("team: cannot close the team\n");
+     return 1;
+   }
+ 
+   if (guyhaderror)
+   {
+     mesg("team: guy had error\n");
      return 1;
    }