-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Command execution returns success on segfault #91
Comments
I'll can take a look at this over the weekend. Btw, I'm looking at some of your CG papers, specifically the volumetric ray paper. I've been writing a graphics engine for fun, and I added crepuscular rays as a post-process effect in screen space. It's got some quirks vs "true" volumetric rays, but it's pretty fast. Looking at your paper though, your implementation seems to have good performance as well... |
Hm, I'm seeing different behavior on linux: import sh
cmd = sh.Command('sh')('-c', 'kill -SEGV $$')
print cmd.exit_code # -11 It makes sense that a progress that ends from a signal does not raise an exception, this was a design decision I made. What doesn't make sense is that you're seeing exit code 139 for the process you're killing. Was 139 for some other process that segfaulted, or can you confirm that you're seeing 139 from the above code too? |
In that case, I'm not clear: Which exit conditions do trigger exceptions, and which don't? Some certainly do, and these segfaults certainly don't, but the distinction is unclear. |
A process that ends from a signal does not raise an exception, and its return code is |
So if you could get back to me on this:
It would help me debug |
That was the exit code I saw in Bash. In Sh, it maps to -11 as you expected. |
Ah ok, so this is expected behavior then. I don't have any plans to change how sh responds to signals that trigger an exit, unless you have a good argument for it. The original reasoning was that if you had a big python script that used |
That's fine, it was just unexpected behavior. I still suspect the opposite behavior might be more predictable (do the obvious, consistent thing of raising all non-zero exit conditions by default; require try/except or a dedicated setting for the use case you're describing), but for my usage I'm fine with this. Actually, it might be useful at least to have an option to force exceptions for all unexpected exits, unifying SIGSEGV or SIGKILL with exit(1) etc. Perhaps an option on the Command object or to its call operator. |
Cool, I'll add a note to the documentation about the current behavior and then close this out |
updated docs live |
Can you revisit this decision? I really don't understand the rationale for not raising an exception when a process exits with a signal. This is a worse situation than erroring out with a positive error code. If the process you called segfaulted, well, something is pretty wrong somewhere down the line, so it should be treated with at least the same severity as a nonzero exit code. Or if you want to treat SIGSEGV and SIGKILL differently, maybe, but I still think that if you kill a long-running process, the whole Python script should also stop. |
We would need to define which signals should throw an exception and which shouldn't. There's quite a few, and it might not be clear on which ones should raise
|
You could always start with a few obvious ones (SIGABRT, SIGALRM, SIGKILL, SIGQUIT, etc), then expand later, depending on what people find. |
Not all of these signals terminate a process. I think any that does terminate a process should raise an exception, i.e. just patch the line
to raise an exception. Sadly, this includes SIGKILL and SIGTERM, but I think it's the right choice. It is, for example, what Perl's IPC::System::Simple does. And whatever else you may think about Perl, they do know their Unix and their signals over there. ;-) |
Thanks, I think this is exactly what was needed. |
Command
s silently succeed when the underlying process segfaults. e.g.:returns without error, where:
raises a non-zero exit code, as expected.
Testing from the shell, the segfaulting processes all do set a non-zero exit code (139), but it is silently dropped by sh. (The same is not true of
subprocess.check_call
.)(This is on OS X 10.8.1, with the latest sh.py from git.)
The text was updated successfully, but these errors were encountered: