-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Provide a system(3) replacement on Android (+ build OCaml on Android) #13405
base: trunk
Are you sure you want to change the base?
Conversation
Not sure what license the code snippets from the POSIX spec are in. However, as an alternative, the code in musl libc is licensed liberally (see https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT?h=v1.2.5 ) (I checked version As an idea one could adapt the code for |
Theoretically, you need to ask IEEE for permission to use parts of the specification in your work (even code examples), and you would need to add the IEEE copyright. I agree borrowing code for other projects with clear open source licences should be preferred. |
d524ddb
to
9c95968
Compare
I've taken the code from musl, it's MIT-licensed. |
posix_spawnattr_setsigmask(&attr, &old); | ||
posix_spawnattr_setsigdefault(&attr, &reset); | ||
posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF|POSIX_SPAWN_SETSIGMASK); | ||
ret = posix_spawn(&pid, "/bin/sh", 0, &attr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you been able to check that posix_spawn
is available on Android? Note that configure
checks for its availability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's been available since Android 8 Oreo.
We already have code that calls |
I'm not sure how. It would mostly require moving parts of Interestingly |
9c95968
to
c107d92
Compare
A breaking but simplifying change could be to stop calling the shell with the preprocessor arguments, and rather invoke the process directly. |
This would fix #13380, where an user reported a failure to build OCaml on Android with Termux. I found out that OCaml internally calls system() (bionic source) in caml_sys_system_command via Ccomp.command and Pparse.call_external_preprocessor. The problem is that
system
seems to have been blocked for security reasons, and thusocamlc
fails at invokinggawk
as an external preprocessor (but note thatgawk
can still be called from the shell):Android hasn't disabled classic ways of spawning processes, and we can re-implement
system(3)
, which this PR does, with code directly taken fromthe POSIX spec (are there licensing issues?)the musl library (MIT-licensed).Do let me know if supporting Android is not an interesting target.
I'm not sure if this implementation of
caml_sys_system
should do smarter things, like unload the runtime after the fork or other cleanups.Is there another way to circumvent this problem?