FROM: Padraig Brady DATE: 07/29/2001 09:07:30 SUBJECT: linuxthreads popen bug? Hi, I'm using glibc 2.1.3 and I'm having very weird problems with multiple threads calling popen() or system(). I looked @ the popen code for glibc 2.2.3 and it didn't differ in any related way I could see, so the "bug" may still exist? First off, is there a list of functions in glibc that are not threadsafe &/or have threadsafe equivalents. It's extremely hard to find this info. OK I looked @ the code for popen() and noticed that it used (an unprotected?) global: static struct _IO_proc_file *proc_file_chain; then proceeed in _IO_new_proc_open() to: /* POSIX.2: "popen() shall ensure that any streams from previous popen() calls that remain open in the parent process are closed in the new child process." */ for (p = proc_file_chain; p; p = p->next) _IO_close (_IO_fileno ((_IO_FILE *) p)); This correlates with what I was seeing with processes created with popen() being stuck in a tight loop trying to close(some_invalid_fd); I was able to confirm this with strace -p CPUhoggingProcessPid Should I just write my_popen() and my_system()? cheers, Padraig.