-
Notifications
You must be signed in to change notification settings - Fork 2
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
Ability to optionally log #1
Conversation
loop { | ||
for signal in signals.pending() { | ||
for signal in signals.forever() { |
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 fixes the busy loop issue. Earlier the above loop caused 100% cpu consumption.
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
let pid = u32::try_from(pid.as_raw()).ok()?; | ||
if pid == child { | ||
graceful_shutdown() |
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.
Calling the abort call previously resulted in the segmentation fault issue.
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
} | ||
|
||
return 0; | ||
} |
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.
Sample program to test that it does reap the orphan process.
let exit_status = ExitStatus { | ||
pid, | ||
// Translate signal to exit code | ||
exit_code: signal as i32 + 128, |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
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 process can exit because of two reasons:
- Normal exit
- Exit via Unix signals
In case of Unix signals, we remap it to proper exit code.
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 get that, but you seem to be conflating the process ID and the exit status.
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.
Do you think renaming it from ExitStatus
to ProcessStatus
will be helpful ?
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.
Can you look over the code one more time from scratch? I think you'll see what I'm talking about: in some branches you're returning a process ID, in some an exit code, and in some a signal, but assigning all of them to a variable called pid.
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 have gone ahead with some renaming which will hopefully help with the confusion.
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.
Can you look over the code one more time from scratch? I think you'll see what I'm talking about: in some branches you're returning a process ID, in some an exit code, and in some a signal, but assigning all of them to a variable called pid.
Sure, I will let you know once it's ready for review. Thanks!
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.
Never mind, I see my confusion, you were completely correct. Sorry for the noise.
src/lib.rs
Outdated
@@ -50,10 +81,12 @@ fn pid1_handling(child: Option<Child>) -> ! { | |||
}; | |||
(|| { | |||
let child = child?; | |||
let pid = pid?; | |||
let child_exit_status = pid?; |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
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.
Sorry for the confusing name, I have renamed it. Can you see if that helps ?
By default it doesn't log. This also fixes the segmentation fault issue that was happening before.