-
Notifications
You must be signed in to change notification settings - Fork 11
Add Android platform support #306
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
Changes from all commits
9310bb7
07a44e2
76b83d4
66025ac
789cdc2
133d25f
a0299f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,18 +32,34 @@ pub async fn spawn( | |
|
|
||
| ///| | ||
| #cfg(not(platform="windows")) | ||
| pub async fn wait_pid(pid : Int, context~ : String) -> Unit { | ||
| pub async fn wait_pid(pid : Int, context~ : String) -> Int? { | ||
| guard curr_loop.val is Some(evloop) | ||
| ignore(context) | ||
| let alt_id = match evloop.poll.register_pid(pid) { | ||
| Running(id) => id | ||
| Stopped => return | ||
| // Try pidfd first (Linux 5.3+), fall back to worker-thread waitpid | ||
| let register_result : RegisterPidResult? = Some(evloop.poll.register_pid(pid)) catch { | ||
| _ => None | ||
| } | ||
| guard evloop.pids.get(alt_id) is None | ||
| evloop.pids[alt_id] = @coroutine.current_coroutine() | ||
| defer { | ||
| evloop.pids.remove(alt_id) | ||
| evloop.poll.remove_pid(alt_id) | ||
| match register_result { | ||
| Some(Running(alt_id)) => { | ||
| guard evloop.pids.get(alt_id) is None | ||
| evloop.pids[alt_id] = @coroutine.current_coroutine() | ||
| defer { | ||
| evloop.pids.remove(alt_id) | ||
| evloop.poll.remove_pid(alt_id) | ||
| } | ||
| @coroutine.suspend() | ||
| None | ||
| } | ||
| Some(Stopped) => None | ||
| None => { | ||
| // pidfd not available, fall back to blocking waitpid in worker thread. | ||
| // The worker reaps the child and stores the exit code in job.ret(), | ||
| // so return it here to avoid a second waitpid in get_process_result. | ||
| let job = Job::wait_for_process(pid) | ||
| let exit_code = perform_job_in_worker(job, context~, cancel=_ => { | ||
| job.cancel_process_waiter() | ||
| NeedWait | ||
|
Comment on lines
+58
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| }) | ||
| Some(exit_code) | ||
| } | ||
| } | ||
| @coroutine.suspend() | ||
| } | ||
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.
This uses
$TMPDIRverbatim on Android, buttmpdir()builds paths by directly concatenatingtmp_base_pathwith the generated name, so a common value like/data/local/tmp(no trailing slash) produces malformed paths such as/data/local/tmpprefix...and can create directories in the wrong location or fail unexpectedly. Normalize the base path (or append/if missing) before returning it.Useful? React with 👍 / 👎.