I have an application that checks its command line parameters and stores values in persistent storage. One of them is a password that I don’t want to stick with so that people can see “ps” and friends. The approach that I am currently considering is that after I have saved the values I need, restart the process without command line options. My naive approach is that args [0] is the application path:
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:[args objectAtIndex:0]];
[task launch];
[task release];
[NSApp terminate:nil];
The child starts up. However, when my application stops, the child does not seem to be an orphan, but gets stuck. Am I just on this?
Additional info: it seems that when I call [NSApp terminate: nil], the NSTask that gets started gets stuck, but if I just exit (), then it works fine. However, I am concerned that the open ones (keychain, plist, etc.) will be in poor condition if I do this.
And note that in most code examples there is some kind of watchdog process that restarts a separate process when necessary. I am trying to restart the current process that is already running from the same process.
source
share