[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

linuxthreads popen bug?

From: Padraig Brady
Subject: linuxthreads popen bug?
Date: Sun, 29 Jul 2001 17:07:30 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010628


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()?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]