• 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: Suspending a task
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suspending a task


  • Subject: Re: Suspending a task
  • From: Alex Zavatone <email@hidden>
  • Date: Wed, 17 Oct 2012 11:53:27 -0400


On Oct 17, 2012, at 8:28 AM, Ken Thomases wrote:

On Oct 17, 2012, at 1:19 AM, Programmingkid wrote:

How do I programmatically suspend a task? I looked at a function called task_suspend(), but I don't know how to make it work. Anyone have any example code that shows how to use this function?

This doesn't appear to have anything to do with Xcode, so it shouldn't be on the Xcode-Users list.

Also, the term "task" is ambiguous.  Do you mean a process?  A thread?  A work item submitted using Grand Central Dispatch?  An NSOperation submitted to an NSOperationQueue?

What language are you programming in and against which frameworks or libraries?  If you're programming in Cocoa and talking about a process, you can use NSTask to launch the process and -[NSTask suspend] to suspend it (and your question should have gone to the Cocoa-Dev list).

You won't easily be able to use task_suspend().  It's part of the Mach APIs, which are esoteric and Apple discourages their use because they aren't officially public APIs.

You can send a process SIGSTOP using the kill() system call to suspend it and then use SIGCONT to unsuspend it.

Regards,
Ken

I routinely use SIGSTOP and SIGCONTs to pause things that are running in the background like Safari.

kill -SIGSTOP theProcessId
kill -SIGCONT theProcessId



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Suspending a task (From: Programmingkid <email@hidden>)
 >Re: Suspending a task (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Suspending a task
  • Next by Date: Re: Suspending a task
  • Previous by thread: Re: Suspending a task
  • Next by thread: Re: Suspending a task
  • Index(es):
    • Date
    • Thread