View Single Post

   
  #10 (permalink)  
Old 01-16-2008, 07:54 PM
Otto Lind
 
Posts: n/a
Default Re: Problem with system() calls in a multithreaded program on HPUX 11

In article <4211a1e8@news.meer.net>,
"Dan Koren" <dankoren@yahoo.com> writes:
>
> Replace 'system(cmd)' by 'pclose(popen(cmd, "w"))' and
> things should work as long as 'cmd' is reasonably well
> behaved.


Note that this will crash if popen() fails, since passing in NULL to
pclose() will cause a segfault. I see this is used as a suggestion
in the popen man page on Solaris (in fact both examples they give
are buggy), they should really fix this so that naive users don't
write broken programs.

Otto
Reply With Quote