From: "Sébastien Carlier" <sebc@cee.hw.ac.uk>
To: caml-list@inria.fr
Subject: [Caml-list] Sys.command is broken on MacOS X
Date: Thu, 1 Aug 2002 10:26:52 +0100 [thread overview]
Message-ID: <D0697156-A530-11D6-9425-00306546978E@cee.hw.ac.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
The system(3) C library function is seriously broken on MacOS X.
It may return with an Interrupted System Call error before the child
process has finished its execution, leaving a zombie process.
The Ocaml function Sys.command uses the system(3) function,
and thus is broken too. Active DVI is one of the applications greatly
impacted by this bug, but there may be others.
The attached patch, to be applied to the Ocaml compiler, provides a
working implementation of the system(3) function. If an Ocaml
application uses Sys.command, and unexpectedly fails on MacOS X
with "Interrupted System Call" errors, you should apply this patch.
--
Sébastien Carlier
[-- Attachment #2: ocaml-macosx-system.patch --]
[-- Type: application/octet-stream, Size: 1251 bytes --]
Index: byterun/sys.c
===================================================================
RCS file: /caml/ocaml/byterun/sys.c,v
retrieving revision 1.59
diff -r1.59 sys.c
256a257,298
> #if defined(SYS_rhapsody)
> int rhapsody_system(const char *string) {
> int old_sigmask;
> pid_t pid;
>
> if (string == 0)
> return 1;
> old_sigmask = sigblock(sigmask(SIGQUIT));
> pid = vfork();
> if (pid < 0) {
> /* vfork failed */
> sigsetmask(old_sigmask);
> return -1;
> } else if (pid == 0) {
> /* We are in the child process */
> sigsetmask(old_sigmask);
> execl("/bin/sh", "sh", "-c", string, 0);
> _exit(127);
> return -1;
> } else {
> /* We are in the parent process */
> int status = 0;
> void* old_sigint;
> void* old_sigquit;
> int result;
>
> old_sigint = signal(SIGINT, 0);
> old_sigquit = signal(SIGQUIT, 0);
> do {
> result = waitpid(pid, &status, 0);
> } while (result < 0 && errno == EINTR);
> signal(SIGINT, old_sigint);
> signal(SIGQUIT, old_sigquit);
> sigsetmask(old_sigmask);
> if (result < 0)
> return -1;
> else
> return status;
> }
> }
> #endif
>
262a305,307
> #if defined(SYS_rhapsody)
> status = rhapsody_system(String_val(command));
> #else
263a309
> #endif
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
reply other threads:[~2002-08-01 9:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D0697156-A530-11D6-9425-00306546978E@cee.hw.ac.uk \
--to=sebc@cee.hw.ac.uk \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox