-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Raises on failure to run a process (Fixes #3517) #3520
Raises on failure to run a process (Fixes #3517) #3520
Conversation
GTG? |
@asterite ping? |
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 should be merged but the implementation should be improved.
@@ -240,14 +244,24 @@ class Process | |||
fork_error || error, | |||
chdir | |||
) | |||
rescue ex : Errno | |||
value = ex.errno | |||
child_sock.write(Bytes.new(pointerof(value).as(UInt8*), 4)) |
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 should use write_bytes
.
ensure | ||
LibC._exit 127 | ||
end | ||
end | ||
|
||
child_sock.close | ||
slice = Bytes.new(4) | ||
if parent_sock.read(slice) == 4 |
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 should use read_bytes
.
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.
No, read_bytes
calls read_fully
which raises when the pipe is closed. Would need read_bytes?
for that.
slice = Bytes.new(4) | ||
if parent_sock.read(slice) == 4 | ||
parent_sock.close | ||
Errno.value = slice.pointer(4).as(Int32*).value |
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.
Shouldn't you just pass the value to Errno
's constructor instead of setting Errno.value
?
Any update on this? |
@lbguilherme will you continue working on this PR? |
Would be great if someone from the community could pick up this abandoned PR |
Can be closed since #6501 was merged. |
This changes the behavior of
Process.new
to block untilexecvp
is performed and raise an exception if it fails. Previous behavior was to return immediately and let the forked process exit with 127. See #3517.Before:
After: