Date: Mon, 31 Jul 2000 13:55:35 +0700 From: Alain Fauconnet <alain@cscoms.net> To: freebsd-questions@freebsd.org Subject: Trouble with waitpid(2) porting poppasswd Message-ID: <20000731135534.A552@cscoms.net>
next in thread | raw e-mail | index | archive | help
Dear all, I am doing a port of the poppasswd utility (well, one of the numerous versions floating) because I have failed to find a port already available. For those who don't know, it's a daemon replying to requests on port #106 "a la POP" for users to change their passwords. There is a couple of source code samples on Eudora.COM because some versions of Eudora can use it on a server. Now to the point: basically what the daemon does is opening a pair of pseudo-ttys and forking a child. The child: - does a setsid(2) to start a new session - opens the slave part of the pty - does dup2(2) of stdin, stdout and stderr to the slave part of the pty - adjusts some terminal attributes (ICANON, ~ONLCR, ~ECHO...) - changes uid and gid to those of the target user - does execl(2) /usr/bin/passwd. Parent will then feed input to the prompts issued by the passwd command. So far, so good. It works (with some changes from the generic version). When everything is done, the parent does a: wpid = waitpid(pid, &wstat, 0) with pid is the value returned by fork(2). Here is the problem: on FreeBSD, the waitpid(2) hangs forever, although the pid is correct and ps shows the child process with status "SE" (trying to exit and sleeping for <30s). If I add the WNOHANG option, waitpid does return but the returned value is 0. This beats me. Why is waitpid ignoring its child ? I even tried to wait on (-pid) (i.e. waiting on the process group ID) with the same result. Can someone please explain me ? I'm not that much a system programmer (I used to be a long time ago...), more a system administrator ! Oh, by the way, this is on FreeBSD 4.0-RELEASE. Many thanks in advance, _Alain_ -- Alain FAUCONNET Sr. System Administrator CS Internet Co. Ltd. (Shin Corp) - Thailand To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000731135534.A552>