Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Calling spawnl() in a multi-threaded process under 6.5.0: (1 Item)
   
Calling spawnl() in a multi-threaded process under 6.5.0  
I have a process that was using system() to start another process (actually the IP stack).

This worked fine until I included some code that started up a second thread.

At this point both the original process and the new process hung during the process creation.

I took this opportunity to switch to spawnl(), which is preferred as it doesn't follow path look-up, but the processes 
still hung.

As the the extra thread was just used to obtain the MAC to be used as a parameter to the IP stack, I modified the code 
to stop the second thread before spawning the IP stack process and it worked fine again.

This implies to me that spawnl() may not work if when the process has multiple threads active.

Now there is docmentation that fork will fail with an error code if you try to use it with multiple threads active but 
the advice suggests that with spawn you just need to be careful about shared data.

Looking at the System Information Perspective:
Process 1 Thread 1: blocked on the kernel.
Process 1 Thread 2:(receives message on channel 1, message is not recognised and thread terminates)
Process 2 main thread: Reply state blocked on process 1.

It looks as though the spawned process has sent a message to channel 1 in the original process.

For the moment I am stopping the second thread before calling spawnl() but I'd appreciate knowing what's going on so I 
can come up with a  more general solution.

Thanks.