From e22007ab78dbef465982ef779014b6b2c7b205a6 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <ossi@kde.org>
Date: Sat, 17 Apr 2010 21:16:36 +0200
Subject: [PATCH] restore signals even if fork() fails
the -1 is not sent through WEXITSTATUS() in case of wait()
failing any more. i think that's the original intention.
---
lib/utilunix.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/utilunix.c b/lib/utilunix.c
index 88e447e..5fac25f 100644
a
|
b
|
my_system (int flags, const char *shell, const char *command) |
167 | 167 | if (pid < 0) |
168 | 168 | { |
169 | 169 | fprintf (stderr, "\n\nfork () = -1\n"); |
170 | | return -1; |
| 170 | status = -1; |
171 | 171 | } |
172 | | if (pid == 0) |
| 172 | else if (pid == 0) |
173 | 173 | { |
174 | 174 | signal (SIGINT, SIG_DFL); |
175 | 175 | signal (SIGQUIT, SIG_DFL); |
… |
… |
my_system (int flags, const char *shell, const char *command) |
204 | 204 | } |
205 | 205 | else |
206 | 206 | { |
207 | | while (waitpid (pid, &status, 0) < 0) |
| 207 | for (;;) |
| 208 | { |
| 209 | if (waitpid (pid, &status, 0) > 0) |
| 210 | { |
| 211 | status = WEXITSTATUS(status); |
| 212 | break; |
| 213 | } |
208 | 214 | if (errno != EINTR) |
209 | 215 | { |
210 | 216 | status = -1; |
211 | 217 | break; |
212 | 218 | } |
| 219 | } |
213 | 220 | } |
214 | 221 | sigaction (SIGINT, &save_intr, NULL); |
215 | 222 | sigaction (SIGQUIT, &save_quit, NULL); |
216 | 223 | sigaction (SIGTSTP, &save_stop, NULL); |
217 | 224 | |
218 | | return WEXITSTATUS (status); |
| 225 | return status; |
219 | 226 | } |
220 | 227 | |
221 | 228 | |