From 036a7d2e1688689f783ebefd53b45eeea061cbfb Mon Sep 17 00:00:00 2001 From: alfred Date: Wed, 3 Oct 2001 11:01:39 +0000 Subject: 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 --- lib/libc/stdlib/system.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib/system.c') 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; } -- cgit v1.1