Aborting Python from C code

Dylan Evans dylan at contentfree.info
Sat Apr 30 05:29:47 EDT 2011

I think i see what you are trying to do but it depends on the environment
and your goals.

Generally i think you need to separate your code by forking (or perhaps you
have already done that?),
then you can run a check to see if the process died as expected. I don't
know though, this not much
information to go on, but if you are running untrusted code then you need to
be able to isolate and kill it.

On Sat, Apr 30, 2011 at 6:17 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Sat, Apr 30, 2011 at 6:08 PM, Miki Tebeka <miki.tebeka at gmail.com>
> wrote:
> >> In our sandboxed Python environment, I would like to be able to
> >> trigger an abort of the currently-running Python script (from a signal
> >> handler or another thread).
> > There's os.abort
> That core dumps the process; what I want is to force the
> PyRun_StringFlags to return. Normally PyErr_SetInterrupt will do
> exactly this (within a few instructions is fine), but the Python
> script is able to prevent that from happening, which I don't like.
> Chris Angelico
> --
> http://mail.python.org/mailman/listinfo/python-list


"The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110430/f1cdf629/attachment.html>

More information about the Python-list mailing list