Skip to content

Commit ec45621

Browse files
committed
cbits: Don't stopTimer until absolutely necessary
Previoussly we would call stopTimer sooner than necessary, then fail to restart the timer if find_exectuable failed. Avoid this by deferring the stopTimer call until we are just about to fork. Closes #283.
1 parent c956562 commit ec45621

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cbits/posix/fork_exec.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,6 @@ do_spawn_fork (char *const args[],
154154
return -1;
155155
}
156156

157-
// Block signals with Haskell handlers. The danger here is that
158-
// with the threaded RTS, a signal arrives in the child process,
159-
// the RTS writes the signal information into the pipe (which is
160-
// shared between parent and child), and the parent behaves as if
161-
// the signal had been raised.
162-
blockUserSignals();
163-
164-
// See #4074. Sometimes fork() gets interrupted by the timer
165-
// signal and keeps restarting indefinitely.
166-
stopTimer();
167-
168157
// N.B. execvpe is not supposed on some platforms. In this case
169158
// we emulate this using fork and exec. However, to safely do so
170159
// we need to perform all allocations *prior* to forking. Consequently, we
@@ -181,6 +170,17 @@ do_spawn_fork (char *const args[],
181170
}
182171
#endif
183172

173+
// Block signals with Haskell handlers. The danger here is that
174+
// with the threaded RTS, a signal arrives in the child process,
175+
// the RTS writes the signal information into the pipe (which is
176+
// shared between parent and child), and the parent behaves as if
177+
// the signal had been raised.
178+
blockUserSignals();
179+
180+
// See #4074. Sometimes fork() gets interrupted by the timer
181+
// signal and keeps restarting indefinitely.
182+
stopTimer();
183+
184184
int pid = fork();
185185
switch(pid)
186186
{

0 commit comments

Comments
 (0)