Skip to content

Commit

Permalink
chore: update spawn
Browse files Browse the repository at this point in the history
- pull some upstream changes including janestreet/spawn#51 (Haiku) and
  janestreet/spawn#52 (Android)
- point to `ocaml-dune/spawn`
- point to a commit instead of a branch name

Signed-off-by: Etienne Millon <[email protected]>
  • Loading branch information
emillon committed Sep 26, 2023
1 parent ab184a4 commit b1597e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions vendor/spawn/src/spawn_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ CAMLprim value spawn_is_osx()

#include <assert.h>
#include <string.h>
#if !defined(__CYGWIN__)
#if !defined(__CYGWIN__) && !defined(__HAIKU__)
#include <sys/syscall.h>
#endif
#include <sys/types.h>
Expand All @@ -88,7 +88,7 @@ CAMLprim value spawn_is_osx()
| pipe2 |
+-----------------------------------------------------------------+ */

#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__HAIKU__)

/* vfork(2) is deprecated on macOS >= 12, so we use fork(2) instead. */
# if defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
Expand Down Expand Up @@ -215,7 +215,11 @@ static void subprocess_failure(int failure_fd,
sigset_t sigset;
ssize_t written;

#ifdef PIPE_BUF
CASSERT(sizeof(failure) < PIPE_BUF)
#else
CASSERT(sizeof(failure) < _POSIX_PIPE_BUF)
#endif

set_error(&failure, errno, function, error_arg);

Expand Down Expand Up @@ -702,8 +706,15 @@ CAMLprim value spawn_unix(value v_env,
For instance:
http://git.musl-libc.org/cgit/musl/tree/src/process/posix_spawn.c
On android, pthread_cancel is not implemented, it is typically
patched out or in certain cases reimplemented with atomic_flags
https://github.com/search?q=org%3Atermux+pthread_setcancelstate+language%3ADiff&type=code&l=Diff
*/

#if !defined(__ANDROID__)
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state);
#endif
sigfillset(&sigset);
pthread_sigmask(SIG_SETMASK, &sigset, &saved_procmask);

Expand Down Expand Up @@ -750,7 +761,9 @@ CAMLprim value spawn_unix(value v_env,

close(result_pipe[0]);
pthread_sigmask(SIG_SETMASK, &saved_procmask, NULL);
#if !defined(__ANDROID__)
pthread_setcancelstate(cancel_state, NULL);
#endif

caml_leave_blocking_section();

Expand Down
4 changes: 2 additions & 2 deletions vendor/update-spawn.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

version=posix_spawn
version=e184beb298d9abe0c524a4839bb0bec3d2571282

set -e -o pipefail

Expand All @@ -12,7 +12,7 @@ mkdir -p spawn/src

(
cd $TMP
git clone https://github.com/rgrinberg/spawn.git
git clone https://github.com/ocaml-dune/spawn.git
cd spawn
git checkout $version
)
Expand Down

0 comments on commit b1597e2

Please sign in to comment.