-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
macOS: killed processes report different exit code in 2.1-preview2 #26010
Comments
It doesn't happen on Linux but I haven't tried on 10.12 or older Mac OS versions. |
The implementation changed from using the The exit code is determined here: For a signal we should hit: Which adds 128 to
|
I can confirm that the same thing happens on macOS Sierra (10.12) with |
Can someone with a mac please run the equivalent of e.g. on Linux I get this:
You can see |
Ok, I digged into this: First of all you need to allow Using this $ sudo dtrace -n '
syscall::waitid:entry
{
self->arg0 = arg0;
self->arg1 = arg1;
self->arg2 = arg2;
}
syscall::waitid:return
{
this->info = (siginfo_t*)copyin(self->arg2, sizeof(siginfo_t));
printf("%s(%i): %s(0x%x%s, %i, {si_signo: 0x%X%s, si_code: 0x%X%s, si_pid: %i, si_status: 0x%X}\n",
execname,
pid,
probefunc,
self->arg0,
self->arg0 == 1 ? " (P_PID)" : self->arg0 == 0 ? " (P_ALL)" : "",
self->arg1,
this->info->si_signo,
this->info->si_signo == 20 ? " (SIGCHLD)" : "",
this->info->si_code,
this->info->si_code == 2 ? " (CLD_KILLED)" : "",
this->info->si_pid,
this->info->si_status);
}
' Output:
It looks like |
cc: @danmosemsft, @ViktorHofer |
@akoeplinger thank you for investigating further! We can fix this regression by using |
Thanks, @tmds. Can you get to this quickly and keep the change to the minimum necessary to fix this (plus test(s))? I'd like to try to get this into 2.1. |
dotnet#26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitpid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to terminated children. Fixes https://github.com/dotnet/corefx/issues/29370
dotnet#26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to terminated children. Fixes https://github.com/dotnet/corefx/issues/29370
dotnet#26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to terminated children. Fixes https://github.com/dotnet/corefx/issues/29370
dotnet#26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to find terminated children. Fixes https://github.com/dotnet/corefx/issues/29370
Sure thing, I'll track dotnet/corefx#29407 & help get it ported once merged. |
* Fix Process.ExitCode on mac for killed processes #26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to find terminated children. Fixes https://github.com/dotnet/corefx/issues/29370 * TestExitCodeKilledChild: remove runtime check * TestExitCodeKilledChild: remove greater than assert
dotnet/corefx#29407 is in, I can put up a port to 2.1 once I get access to my machine (should be tomorrow). |
* Fix Process.ExitCode on mac for killed processes dotnet#26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to find terminated children. Fixes https://github.com/dotnet/corefx/issues/29370 * TestExitCodeKilledChild: remove runtime check * TestExitCodeKilledChild: remove greater than assert
I can take care of this now so that we don't need to wait till tomorrow. Will send the PR soon. |
* Fix Process.ExitCode on mac for killed processes #26291 changed process reaping from using waitpid to waitid. This caused a regression on mac, since for processes that are killed, (on mac) waitid does not return the signal number that caused the process to terminated. We change back to waitpid for reaping children and determining the exit code. waitid is used to find terminated children. Fixes https://github.com/dotnet/corefx/issues/29370 * TestExitCodeKilledChild: remove runtime check * TestExitCodeKilledChild: remove greater than assert
This was fixed in release/2.1 branch via PR dotnet/corefx#29445 |
The 2.0 behavior matches my shells and some searching: it's
SIGKILL
(9) + exited-due-to-signal (128).This was discovered when we updated MSBuild to use the preview2 runtime for testing (worked around with dotnet/msbuild@a476aa5). The repro there is fairly complicated, since we don't use
Process.Kill()
, instead manually killing an entire process tree.In MSBuild, we sent
SIGTERM
and expect 143 instead of 137, but I assume it's the same underlying cause.Mono does not exhibit this behavior on macOS High Sierra, so I don't think it's an OS change.
dotnet --info
The text was updated successfully, but these errors were encountered: