Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 507621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:49:24+00:00 2026-05-13T06:49:24+00:00

On OS X 10.4/5/6: I have a parent process which spawns a child. I

  • 0

On OS X 10.4/5/6:

I have a parent process which spawns a child. I want to kill the parent without killing the child. Is it possible? I can modify source on either app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:49:24+00:00Added an answer on May 13, 2026 at 6:49 am

    As NSD asked, it really depends on how it is spawned. If you are using a shell script, for example, you can use the nohup command to run the child through.

    If you are using fork/exec, then it is a little more complicated, but no too much so.

    From http://code.activestate.com/recipes/66012/

    import sys, os 
    
    def main():
        """ A demo daemon main routine, write a datestamp to 
            /tmp/daemon-log every 10 seconds.
        """
        import time
    
        f = open("/tmp/daemon-log", "w") 
        while 1: 
            f.write('%s\n' % time.ctime(time.time())) 
            f.flush() 
            time.sleep(10) 
    
    
    if __name__ == "__main__":
        # do the UNIX double-fork magic, see Stevens' "Advanced 
        # Programming in the UNIX Environment" for details (ISBN 0201563177)
        try: 
            pid = os.fork() 
            if pid > 0:
                # exit first parent
                sys.exit(0) 
        except OSError, e: 
            print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror) 
            sys.exit(1)
    
        # decouple from parent environment
        os.chdir("/") 
        os.setsid() 
        os.umask(0) 
    
        # do second fork
        try: 
            pid = os.fork() 
            if pid > 0:
                # exit from second parent, print eventual PID before
                print "Daemon PID %d" % pid 
                sys.exit(0) 
        except OSError, e: 
            print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror) 
            sys.exit(1) 
    
        # start the daemon main loop
        main() 
    

    This is one of the best books ever written. It covers these topics in great and extensive detail.

    Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series) (Paperback)

    ISBN-10: 0321525949
    ISBN-13: 978-0321525949

    5 star amazon reviews (I’d give it 6).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a classical map-reduce program in which I have a parent that spwans
I have a parent form which saves the settings and changes user puts. But
i have to write program, which will create two child processes These processes would
I have what seems to be a fairly common inter-process communication requirement - a
I read the documentation for Process.StandardOutput , which has this quote: A deadlock condition
I have several questions about the PE subsystem field, which may overlap to some
first post here so be nice ;) Is it possible to store a FILE
I am hacking away at a uni assignment and have come across a problem
I am having some trouble understanding how to use Unix's fork() . I am
I googled this for the past two weeks and I didn't get any answer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.