[Adium-devl] Let's abandon disk images

Peter Hosey boredzo at gmail.com
Sat Mar 31 23:29:48 UTC 2007


On Mar 31, 2007, at 14:38:37, Ofri Wolfus wrote:
> 2. fork/exec.

There are two problems with this:
1. If the child process (ostensibly `diskutil eject` or something)  
tries to do the eject before its parent has exited, the parent's  
executable file and probably various resources are still in use, so  
the eject will fail.
2. Whenever the parent process exits, it will take the child process  
with it.

Problem 2 can be solved by using ptrace to detach from the child (I  
think—I've never tried). Alternatively, using signal(2) to block  
SIGHUP may work.

Problem 1 can be solved by using a shell script, which you could pass  
to exec:

	static const char eject_argv[][] = {
		"bash", "-c",
		/*Something like the script Graham suggested*/,
		NULL
	};
	pid_t pid = execvp("bash", eject_argv);

___________________________________
\ Peter Hosey / boredzo at adiumx.com
PGP public key ID: C6550423 (since 2007-01-01)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070331/94cf6001/attachment.sig>


More information about the devel mailing list