[Newbies] Canceling a PipeableOSProcess

David T. Lewis lewis at mail.msen.com
Sat Nov 5 00:17:56 UTC 2011


On Fri, Nov 04, 2011 at 01:53:25PM -0700, Sean P. DeNigris wrote:
> How do I cancel a running PipeableOSProcess that is taking a long time, like
> ctrl-c at the command line?

You can kill the external process with a unix signal like this:

  p := PipeableOSProcess command: '/bin/sh'.
  p processProxy terminate.

However, in general, it is better to permit the external process to exit
normally. Usually this just involves closing the input to the process
and reading any available output. For example, if you run /bin/sh in a
PipeableOSProcess, you can terminate it simply by closing the input to
the shell to allow the shell to exit normally, which may be done like
this:

  p := PipeableOSProcess command: '/bin/sh'.
  p close.

Try stepping through these examples in the Smalltalk debugger to get a
better understanding of what is actually being done. Note that it is
entirely possible to send the exact equivalent of ctrl-c (which is a
unix SIGINT signal sent to the process) if you need to do so. See
method UnixOSProcessAccessor>>primSendSigintTo: to see how it is done.
But I suspect that you do not really need to do this, and I am only
mentioning it in case you are interested in the gory details ;)

HTH,
Dave



More information about the Beginners mailing list