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

Have a Parent process which spawns multipe child process via fork. I want the
I have a parent process which spawns a certain number of child processes. Those
I have a parent and child process, and the parent can read output from
Suppose I have a process which spawns exactly one child process. Now when the
what does kill exactly do? I have a parent process which is creating 100
I have a child process which runs in a pseudo terminal. The parent process
I have a parent process which forks out a child to perform execv(). I
I am currently trying to communicate a parent process which should have multiple children
I have a parent and a child process written in C language. Somewhere in
I have parent/child relationship set up via Node Reference. A Child record can have

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.