popen multithreading problem 
Author Message
 popen multithreading problem

I'm having a problem using popen in a multithreading program.
popen is mt-unsafe, so I serialized it as follows:

mutex_lock(&m);
cout <<"right before popen"<<endl;
perlstdout = popen( temp, "r" );
cout <<"right after popen"<<endl;
mutex_unlock(&m);

but the above code always hang up right at popen.
does anyone know what's wrong?

thanks in advance



Wed, 05 Jan 2000 03:00:00 GMT  
 popen multithreading problem



Quote:
>mutex_lock(&m);
>cout <<"right before popen"<<endl;
>perlstdout = popen( temp, "r" );
>cout <<"right after popen"<<endl;
>mutex_unlock(&m);
>but the above code always hang up right at popen.
>does anyone know what's wrong?

This is really a UNIX question, not C, but my guess is
that you can't exec from a critical region.  popen()
spawns a subprocess.


Thu, 06 Jan 2000 03:00:00 GMT  
 popen multithreading problem


Quote:
>I'm having a problem using popen in a multithreading program.
>popen is mt-unsafe, so I serialized it as follows:

>mutex_lock(&m);
>cout <<"right before popen"<<endl;
>perlstdout = popen( temp, "r" );
>cout <<"right after popen"<<endl;
>mutex_unlock(&m);

>but the above code always hang up right at popen.
>does anyone know what's wrong?

Possibly you're only guarding popen and not other file system calls
that may be occurring.  For example, another thread may be doing I/O
during the popen.  If the file system (as opposed to just popen) is
not mt-safe, then {*filter*} things will happen.  To guard against that,
you'd have to do a lock around all of the I/O calls.

--
Ray Fischer        



Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem with popen in DevStudio .NET

2. Problems with popen command

3. popen problem

4. popen() problem

5. peculiar problem with popen/pclose (with lq-text)

6. fread() and popen() problems

7. problems w/ multithreading Fortran using C longjmp

8. Oracle8 & NT Multithreading problems

9. MultiThreading and SingleThread Problem?

10. multithreading problem with dcom

11. Multithreading problem

12. multithreading problem

 

 
Powered by phpBB® Forum Software