comparison svr-chansession.c @ 1826:eaa2d7240a5d

Move comment to svr_chansess_checksignal() where it belongs
author Matt Johnston <matt@ucc.asn.au>
date Mon, 11 Oct 2021 15:13:42 +0800
parents f0cd000f3bca
children 3f0ac6bc58a1
comparison
equal deleted inserted replaced
1825:7a0068effc65 1826:eaa2d7240a5d
80 struct ChanSess *chansess = (struct ChanSess*)channel->typedata; 80 struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
81 TRACE(("sesscheckclose, pid is %d", chansess->exit.exitpid)) 81 TRACE(("sesscheckclose, pid is %d", chansess->exit.exitpid))
82 return chansess->exit.exitpid != -1; 82 return chansess->exit.exitpid != -1;
83 } 83 }
84 84
85 /* Handler for childs exiting, store the state for return to the client */
86
87 /* There's a particular race we have to watch out for: if the forked child
88 * executes, exits, and this signal-handler is called, all before the parent
89 * gets to run, then the childpids[] array won't have the pid in it. Hence we
90 * use the svr_ses.lastexit struct to hold the exit, which is then compared by
91 * the parent when it runs. This work correctly at least in the case of a
92 * single shell spawned (ie the usual case) */
85 void svr_chansess_checksignal(void) { 93 void svr_chansess_checksignal(void) {
86 int status; 94 int status;
87 pid_t pid; 95 pid_t pid;
88 96
89 if (!ses.channel_signal_pending) { 97 if (!ses.channel_signal_pending) {
125 #endif 133 #endif
126 } else { 134 } else {
127 /* we use this to determine how pid exited */ 135 /* we use this to determine how pid exited */
128 ex->exitsignal = -1; 136 ex->exitsignal = -1;
129 } 137 }
130 138 }
131 } 139 }
132 } 140
133
134 /* Handler for childs exiting, store the state for return to the client */
135
136 /* There's a particular race we have to watch out for: if the forked child
137 * executes, exits, and this signal-handler is called, all before the parent
138 * gets to run, then the childpids[] array won't have the pid in it. Hence we
139 * use the svr_ses.lastexit struct to hold the exit, which is then compared by
140 * the parent when it runs. This work correctly at least in the case of a
141 * single shell spawned (ie the usual case) */
142 static void sesssigchild_handler(int UNUSED(dummy)) { 141 static void sesssigchild_handler(int UNUSED(dummy)) {
143 struct sigaction sa_chld; 142 struct sigaction sa_chld;
144 143
145 const int saved_errno = errno; 144 const int saved_errno = errno;
146 145