@@ -54,12 +54,14 @@ module System.Process (
54
54
-- $ctlc-handling
55
55
56
56
-- * Process completion
57
+ -- ** Notes about @exec@ on Windows
58
+ -- $exec-on-windows
57
59
waitForProcess ,
58
60
getProcessExitCode ,
59
61
terminateProcess ,
60
62
interruptProcessGroupOf ,
61
63
62
- -- Interprocess communication
64
+ -- * Interprocess communication
63
65
createPipe ,
64
66
createPipeFd ,
65
67
@@ -394,6 +396,32 @@ processFailedException fun cmd args exit_code =
394
396
-- For even more detail on this topic, see
395
397
-- <http://www.cons.org/cracauer/sigint.html "Proper handling of SIGINT/SIGQUIT">.
396
398
399
+ -- $exec-on-windows
400
+ --
401
+ -- Note that processes which use the POSIX @exec@ system call (e.g. @gcc@)
402
+ -- require special care on Windows. Specifically, the @msvcrt@ C runtime used
403
+ -- frequently on Windows emulates @exec@ in a non-POSIX compliant manner, where
404
+ -- the caller will be terminated (with exit code 0) and execution will continue
405
+ -- in a new process. As a result, on Windows it will appear as though a child
406
+ -- process which has called @exec@ has terminated despite the fact that the
407
+ -- process would still be running on a POSIX-compliant platform.
408
+ --
409
+ -- Since many programs do use @exec@, the @process@ library exposes the
410
+ -- 'use_process_jobs' flag to make it possible to reliably detect when such a
411
+ -- process completes. When this flag is set a 'ProcessHandle' will not be
412
+ -- deemed to be \"finished\" until all processes spawned by it have
413
+ -- terminated (except those spawned by the child with the
414
+ -- @CREATE_BREAKAWAY_FROM_JOB@ @CreateProcess@ flag).
415
+ --
416
+ -- Note, however, that, because of platform limitations, the exit code returned
417
+ -- by @waitForProcess@ and @getProcessExitCode@ cannot not be relied upon when
418
+ -- the child uses @exec@, even when 'use_process_jobs' is used. Specifically,
419
+ -- these functions will return the exit code of the *original child* (which
420
+ -- always exits with code 0, since it called @exec@), not the exit code of the
421
+ -- process which carried on with execution after @exec@. This is different from
422
+ -- the behavior prescribed by POSIX but is the best approximation that can be
423
+ -- realised under the restrictions of the Windows process model.
424
+
397
425
-- -----------------------------------------------------------------------------
398
426
399
427
-- | @readProcess@ forks an external process, reads its standard output
0 commit comments