summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-10-03 11:01:39 +0000
committeralfred <alfred@FreeBSD.org>2001-10-03 11:01:39 +0000
commit036a7d2e1688689f783ebefd53b45eeea061cbfb (patch)
tree0219a40db31f5dd59337537729af770f6b41f53c /lib/libc/stdlib
parentfb11970d9b2635eb11c0f1598f313c9a4d5464f4 (diff)
downloadFreeBSD-src-036a7d2e1688689f783ebefd53b45eeea061cbfb.zip
FreeBSD-src-036a7d2e1688689f783ebefd53b45eeea061cbfb.tar.gz
Avoid getting stuck in system(3) when the internal call to wait4()
is interrupted by saving the pid. The old code would assign the return value to pid which would trash it, to fix the problem save a copy of the pid to be used as the paramter to wait4(). Submitted by: Toshihiko ARAI <toshi@jp.FreeBSD.org>
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/system.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 3b16454..28c9617 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -53,7 +53,7 @@ int
__system(command)
const char *command;
{
- pid_t pid;
+ pid_t pid, savedpid;
int pstat;
struct sigaction ign, intact, quitact;
sigset_t newsigblock, oldsigblock;
@@ -86,8 +86,9 @@ __system(command)
execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
_exit(127);
default: /* parent */
+ savedpid = pid;
do {
- pid = _wait4(pid, &pstat, 0, (struct rusage *)0);
+ pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0);
} while (pid == -1 && errno == EINTR);
break;
}
OpenPOWER on IntegriCloud