diff options
| author | Werner Koch <[email protected]> | 2014-04-15 10:25:45 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2014-04-15 10:25:45 +0000 | 
| commit | 2bb26185e3b9a048033c559517d6ba7d2eb47066 (patch) | |
| tree | cb0d3d179874e2bcd4244638b1b0798bf11f8641 | |
| parent | Actually implement flags for gpgme_op_spawn. (diff) | |
| download | gpgme-2bb26185e3b9a048033c559517d6ba7d2eb47066.tar.gz gpgme-2bb26185e3b9a048033c559517d6ba7d2eb47066.zip | |
Fix possible zombie processes.
* src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR.
(_gpgme_io_dup): Likewise.
(_gpgme_io_connect): Likewise.
--
GnuPG-bug-id: 1630
| -rw-r--r-- | src/posix-io.c | 17 | 
1 files changed, 14 insertions, 3 deletions
| diff --git a/src/posix-io.c b/src/posix-io.c index 908c1ee9..ac823fc8 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -340,10 +340,15 @@ int  _gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal)  {    int status; +  pid_t ret;    *r_status = 0;    *r_signal = 0; -  if (_gpgme_ath_waitpid (pid, &status, hang? 0 : WNOHANG) == pid) +  do +    ret = _gpgme_ath_waitpid (pid, &status, hang? 0 : WNOHANG); +  while (ret == (pid_t)(-1) && errno == EINTR); + +  if (ret == pid)      {        if (WIFSIGNALED (status))  	{ @@ -697,7 +702,11 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)  int  _gpgme_io_dup (int fd)  { -  int new_fd = dup (fd); +  int new_fd; + +  do +    new_fd = dup (fd); +  while (new_fd == -1 && errno == EINTR);    TRACE1 (DEBUG_SYSIO, "_gpgme_io_dup", fd, "new fd==%i", new_fd); @@ -727,7 +736,9 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)    TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_connect", fd,  	      "addr=%p, addrlen=%i", addr, addrlen); -  res = ath_connect (fd, addr, addrlen); +  do +    res = ath_connect (fd, addr, addrlen); +  while (res == -1 && errno == EINTR);    return TRACE_SYSRES (res);  } | 
