• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Terminating a task
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Terminating a task


  • Subject: Re: Terminating a task
  • From: p3consulting <email@hidden>
  • Date: Tue, 21 Oct 2003 20:29:16 +0200

> If I have some code which is using NSTask's waitUntilExit call to
> determine when the task has been completed, is it possible to intervene
> at all (such as a Stop/Cancel button being pressed) to call a terminate
> method, or is waitUntilExit built so it can't be interrupted?
>
> - (void) waitUntilExit
> Suspends your program until the receiver is finished. This method first
> checks to see if the receiver is still running using isRunning . Then
> it polls the current run loop using NSDefaultRunLoopMode until the task
> completes.
>
> This was the text from Apple's reference page for NSTask, so it doesn't
> seem overly possible. Any ideas?
>
> Chad Armstrong
> email@hidden

And in the very same documentation:

interrupt

- (void)interrupt

Sends an interrupt signal to the receiver and all of its subtasks. If
the task terminates as a result, which is the default behavior, an
NSTaskDidTerminateNotification gets sent to the default notification
center. This method has no effect if the receiver was already launched
and has already finished executing. If the receiver has not been
launched yet, this method raises an NSInvalidArgumentException.

It is not always possible to interrupt the receiver because it might be
ignoring the interrupt signal. interrupt sends SIGINT.

terminate

- (void)terminate

Sends a terminate signal to the receiver and all of its subtasks. If
the task terminates as a result, which is the default behavior, an
NSTaskDidTerminateNotification gets sent to the default notification
center. This method has no effect if the receiver was already launched
and has already finished executing. If the receiver has not been
launched yet, this method raises an NSInvalidArgumentException.

It is not always possible to terminate the receiver because it might be
ignoring the terminate signal. terminate sends SIGTERM.

processIdentifier

- (int)processIdentifier

Returns the receiver's process identifier.

So knowing the pid you could also signal (man signal) the process a
SIGKILL if neither interrupt or terminate work




Pascal Pochet
P3 Consulting
email@hidden
http://www.p3-consulting.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Terminating a task
  • Next by Date: RE: setting the increment of all steppers
  • Previous by thread: Re: Terminating a task
  • Next by thread: Mouse Movements in a Drawer
  • Index(es):
    • Date
    • Thread