utils/fork: handle termsig in safe_fork#10686
Conversation
|
Review period will end on 2021-02-24 at 21:42:58 UTC. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
I'd rather we didn't use Marshall here, sorry 😭
Library/Homebrew/utils/fork.rb
Outdated
There was a problem hiding this comment.
| error_hash["status"] = Base64.encode64(Marshal.dump(e.status)) | |
| error_hash["status"] = e.status&.exitstatus |
and instead never assume that this is non-nil.
There was a problem hiding this comment.
Fair enough on Marshal, but the problem isn't status being nil. It's exitstatus being nil. If exitstatus is nil, then we need to use termsig (see ErrorDuringExecution and its handling of a Process::Status object). So will have to change around the API a bit (both exitstatus and termsig are integers and we need to differentiate between the two if we pass it here).
There was a problem hiding this comment.
Changing API around seems fine to me. As long as we assume non-zero status code I don't think preserving this is super critical (but I'll happily see a more comprehensive fix)
|
Review period ended. |
ceb3d46 to
c158e19
Compare
|
This way should be the cleanest/least disruptive. |
7b6c212 to
db8f9ce
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good so far, nice work on this cleanup!
db8f9ce to
f079373
Compare
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?When
safe_forkfails due to application termination rather than exist,exitstatuswill be nil. Instead we should pass more of the object, as it has other methods liketermsigfor those cases. When you passErrorDuringExecutionaProcess::Statusobject, it will handle that and provide proper information on the failure, rather than choking because the passed exit status is nil.It is unfortunately impossible to create a
Process::Statusobject without usingMarshal.load. There is no security risk though as this isn't user input.Fixes #10661.