Pthreads + forking to run files
I'm using Debian 2.4.18 and have a problem with mounting/unmounting USB storage devices from within an application program. I can mount/unmount the devices fine from the shell.
The program is multithreaded usign pthreads. When I try and fork a new process in which I execv the mount/unmount system call, the child process does not seem to run. Fork returns for the parent process with the valid child process id but never returns (with 0) for the child process. ps -ef shows the process id for the child as myprogram <defunct>.
If I wait for the child process to terminate from the parent process using waitpid it never returns.
If I change the program not to use pthreads it works fine.
Alternatively, is there a way to configure the USB device (dev/sda1) to auto mount and unmount when the device is plugged / unplugged?
|