Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update spawn #8768

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading