Mercurial > dropbear
comparison svr-chansession.c @ 96:b8e36c1a5520
Mention the race condition between setting the childpid entry, and
the child exiting.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 18 Aug 2004 16:42:08 +0000 |
parents | 6539c9480b23 |
children | 10f4d3319780 |
comparison
equal
deleted
inserted
replaced
95:b855bf63766c | 96:b8e36c1a5520 |
---|---|
76 struct ChanSess * chansess; | 76 struct ChanSess * chansess; |
77 struct sigaction sa_chld; | 77 struct sigaction sa_chld; |
78 | 78 |
79 TRACE(("enter sigchld handler")); | 79 TRACE(("enter sigchld handler")); |
80 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { | 80 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { |
81 | |
82 /* find the corresponding chansess */ | 81 /* find the corresponding chansess */ |
83 for (i = 0; i < svr_ses.childpidsize; i++) { | 82 for (i = 0; i < svr_ses.childpidsize; i++) { |
84 if (svr_ses.childpids[i].pid == pid) { | 83 if (svr_ses.childpids[i].pid == pid) { |
85 | 84 |
86 chansess = svr_ses.childpids[i].chansess; | 85 chansess = svr_ses.childpids[i].chansess; |
628 } else { | 627 } else { |
629 /* parent */ | 628 /* parent */ |
630 TRACE(("continue noptycommand: parent")); | 629 TRACE(("continue noptycommand: parent")); |
631 chansess->pid = pid; | 630 chansess->pid = pid; |
632 | 631 |
633 /* add a child pid */ | 632 /* add a child pid - Beware: there's a race between this, and the |
633 * exec() called from the child. If the child finishes before we've | |
634 * done this (ie if it was a shell builtin and fast), we won't return a | |
635 * proper return code. For now, we ignore this case. */ | |
634 addchildpid(chansess, pid); | 636 addchildpid(chansess, pid); |
635 | 637 |
636 close(infds[FDIN]); | 638 close(infds[FDIN]); |
637 close(outfds[FDOUT]); | 639 close(outfds[FDOUT]); |
638 close(errfds[FDOUT]); | 640 close(errfds[FDOUT]); |