Discussion:
system("mkdir -p /tmp/20051128") never returns
(too old to reply)
egokhman
2005-11-26 00:29:57 UTC
Permalink
Hi,

I inherited from someone a multithreaded application that issues about 20 or
so system() calls. All similar to:

system("mkdir -p /tmp/20051124");
(Please hold your flames over the usage of system() in multi-threaded
application :-) )
after some time of execution it issues the
system("mkdir -p /tmp/20051128")
which never returns. Could someone recommend a possible theory why it could
happen and suggest a strategy of debugging it?

Note, I have absolutely no problems typing "mkdir -p /tmp/20051128" in a
separate shell window and executing it.

HELP!!!!

Thanx,
Ed Gokhman
noi
2005-11-26 22:38:57 UTC
Permalink
Post by egokhman
Hi,
I inherited from someone a multithreaded application that issues about 20
system("mkdir -p /tmp/20051124");
(Please hold your flames over the usage of system() in multi-threaded
application :-) )
after some time of execution it issues the system("mkdir -p
/tmp/20051128")
which never returns. Could someone recommend a possible theory why it
could happen and suggest a strategy of debugging it?
Note, I have absolutely no problems typing "mkdir -p /tmp/20051128" in a
separate shell window and executing it.
HELP!!!!
Thanx,
Ed Gokhman
Don't know. Is this C/C++, i = system() ? Or Bash try exec() instead?
In either case maybe the command is failing or the return was lost in the
multi-threaded env. Maybe you could move the temp dir allocation to the
start of the application with error messages if the allocation fails.
Scott Lurndal
2005-11-30 18:24:42 UTC
Permalink
Post by egokhman
Hi,
I inherited from someone a multithreaded application that issues about 20 or
system("mkdir -p /tmp/20051124");
(Please hold your flames over the usage of system() in multi-threaded
application :-) )
after some time of execution it issues the
system("mkdir -p /tmp/20051128")
which never returns. Could someone recommend a possible theory why it could
happen and suggest a strategy of debugging it?
Don't use system in a multithreaded application and system(3) won't
hang. Internally system(3) is neither thread-safe, nor re-entrant.

scott

Loading...