-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[stdlib] Adds functionality to spawn and manage processes from exec. file #3998
base: main
Are you sure you want to change the base?
[stdlib] Adds functionality to spawn and manage processes from exec. file #3998
Conversation
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.
Good work so far, just a few fixes.
stdlib/test/os/test_process.mojo
Outdated
|
||
def main(): | ||
test_process_run() | ||
# TODO: How can exception being raised on missing file be asserted |
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.
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.
The issue here from what I understand seems to be that I am rasing the exception in the forked child process when we don't find the executable file ... which try
actually handles gracefully ... so this works fine:
try:
_ = Process.run("file_does_not_exist", List[String]())
except e:
print(e)
But for some reason (I assume related to the raise being in a different process) when try to validate the raise with:
with assert_raise():
_ = Process.run("file_does_not_exist", List[String]())
It crashed the test suite with a no such process error. 🤔
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.
I think that raises
in a fork pre-exec is unsound, you'll need to check before you fork.
- Adds fork, execvp, kill system call utils. to Mojos cLib binds - Adds utility struct. to allow spawning and managing child processes from an executable file - `run` factory method that creates process and returns "management" object - Instance methods to send signals to child process, INT, HUP, KIL Signed-off-by: Hristo I. Gueorguiev <[email protected]>
ba4b3a1
to
6342634
Compare
- Move `process` related code to its own file - Use `vfork` to avoid issues with threading until they are resolved in Mojo - Sending signals to process returns success status - Docstr additions Signed-off-by: Hristo I. Gueorguiev <[email protected]>
6342634
to
63a5a80
Compare
Adds vfork, execvp, kill system call utils. to Mojos cLib binds
Adds utility struct. to allow spawning and managing child processes
from an executable file
run
factory method that creates process and returns "management"object
Ex.: