in reply to Stopped child hangs parent

It is possible for the executable to stop itself or so it seems.

I take it your are talking about the command run by system(). What do you know about the state of the process when it is stopped, what causes it to stop and what its natural course is if you don't signal it? Can you say what the command is?

The problem is when the subprocess stops like this the parent also stops.

If you mean that the child process of your main perl process waits until the system call returns, this is the way system works. If you mean the parent perl process stops, what do you know about the process when it is stopped? Is it some particular function that does not complete?

I tried to capture the stop in both the parent and child but no luck.

Do you mean that the signal was received by your process but your signal handler was not called? Or was no stop signal received?

Replies are listed 'Best First'.
Re^2: Stopped child hangs parent
by jafoba (Novice) on Aug 10, 2009 at 14:38 UTC

    The command is arsload which is a document ingestion utility for IBM DB2 OnDemand Content Manager. I am forcing an error condition which causes this situation. When I run the same command on the command line I get a message telling the pid was stopped. When running my script I am sing top and see the parent and child threads in 'stop' state. If I do not send the SIGCONT signal nothing happens. The processes remain in the 'stop' state. If I send the signal just to the child, the parent remains stopped. I have to signal the parent as well.

    As for the parent, the while loop at the end of the script should output every 5 seconds to show it is waiting. Nothing is output even if I signal the child to continue which ends the child.

    I tried SIG{STOP} = sub {print STDERR "$$ stopped\n";}; in the child and nothing was output. I then tried it in the parent and nothing was output.

    Maybe I am being mislead by the stop state thinking it is the stop signal? For debug purposes only, I have been toying with the idea of putting in a signal handler for almost every signal.

      When the error condition occurs I expect you will have three processes: a parent perl process, a child perl process and an arsload process. Are all three stopped?

      SIGSTOP can't be caught or ignored but SIGTSTP, SIGTTIN and SIGTTOU can. All four signals stop a process by default. The latter two are usually generated only for processes running in the background. Are you running your program in the background?

      You could initiate a separate process group in your child process: see Complete Dissociation of Child from Parent. If you do this then any signals sent from the arsload process to all processes in the process group should not affect the parent process.

      Your parent process should receive a SIGCHLD when its child is stopped. If it is not stopped itself then it can send a SIGCONT.

        Yes you are correct. The arsload process is also stopped. I was concentrating on the Perl processes so intently I completely missed the arsload process.

        When I am testing I am running in the background. When run for real it will run from cron. I was not at a point where I was ready to test it for real yet but based on your question I ran it in the foreground. Everything worked perfectly.

        I will look into daemonize'ing the child process as well. Unless there is something else anyone can think of I may be doing wrong, I believe I am good as long as I do not test in the background.

        Thank you for everything.