site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=i5nCHBDFKotqIfNnE4zBWI6rNABxY/FsI+4FeLdErNA=; b=g6o3w1O4f8jmNAHEsCE5E+CBYU07r525h0BB4It4bF+rzxChKhUX/w/pbGkJ4RKxnf aoDz9rCWdy1uOqE9if4ji3HVmmqmzR0z2DYLD8+Nd3xH3KrSeSiGOGNRsLFEE8hMjQuQ xx//mdp34FQMTKprBmYOaDnsVHeS3c7cxk1t8= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=KiovugYVsquF68gARb3l/U76WW8TW6Lth4jd5gUY2bMsCeWP9CIggyL5TgNueOV0l1 bExHW0quqyu494uHaodt4kSGA8lIn5GLtZI7NDk0dHmTR7thy0MvEhEmPpOiYsrTx2jV K4SKnLjOF8IAnX/tcw+f6IlQSXMAYrRROmd+o= On Jan 27, 2009, at 13:22 , Rakesh Singhal wrote: It is very simple. There is nothing like daemon and not related to usb device. One process is launching another GUI application thats all. Only to launch the GUI, I am looking for different APIs. Obviously I have to support both 10.4 and 10.5. 1. LSOpenApplication() 2. execl() 3. system() Hi Rakesh, // Prepare to launch the new application pid_t pid = fork(); Jason _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... You have to separate your process group from the original process group. When you get a kill signal, it's propagated to the entire process group, which is why your GUI application is terminating when your non-GUI process receives a kill signal. You have two basic ways you can do this. The daemon(3) library call will sever your process group, your tty connections and do other clean-up. If you only want to sever your process group, you can do something like this: if( pid == 0 ) { // child process setsid(); // this will sever the relationship to the parent's process group and controlling terminal execl( "/Applications/TextEdit.app/Contents/MacOS/TextEdit", "/ Applications/TextEdit.app/Contents/MacOS/TextEdit", NULL); // if the child gets here, an error occurred in execl(2) fprintf(stderr, "Error executing application: %s", strerror(errno)); return -1; } // Original parent continues to do whatever it wants... it will now longer pass any signals to the newly loaded GUI image In general, the call to setsid(2) can be replaced with daemon(3), although daemon(3) will do some other things, like change the directory and is really meant for a terminal-based application that wants to disassociate itself from its controlling terminal process (the call to daemon(3) includes the fork(2) call) and is, therefore, discouraged from use in favor of tools like launchd(8). This email sent to site_archiver@lists.apple.com