I have a timeout command that is not timing out.

user@db:~$ ps aux | grep 'timeout'
user       4979  0.0  0.0   4440   628 pts/144  S+   18:52   0:00 sh -c timeout 16 mycommand
user       4980  0.0  0.0  11716   680 pts/144  S    18:52   0:00 timeout 16 mycommand

user@db:~$ ps -p 4980 -o etime=

A conundrum for me. This is the exact opposite of what I need to happen, and I am not sure the best place to begin to troubleshoot this problem. I do not know much of the lower level system stuff in *nix systems.

I would like to know

what is the best approach to troubleshooting a hanging command on a *nix system?

Is there a log or other system info from which I can gather valuable information?

Is there another solid approach to running a command with a time out before it is sent a term signal?

plus all other relevant info...

Also I realize this could be a situation with 'mycommand', so I will note the the actual command being used is a ffmpeg command.

Also note that timeout works as expected, most of the time.

  • 1
    You could try tracing it with strace -p 4980 to see what it's doing. – Celada Feb 12 '15 at 2:45
  • @Celada sudo strace -p 4980 gets this output : Process 4980 attached - interrupt to quit wait4(4981, I am looking up wait4 now... – BryanK Feb 12 '15 at 2:49
  • So it's waiting for the subprocess to finish. My guess is that it already tried to kill it but the subprocess ignored the termination signal (SIGTERM). In that case, timeout just keeps waiting for it unless you give it the -k option to force it to kill the child (with SIGKILL). Do you know if mycommand sets itself up to ignore SIGTERM? – Celada Feb 12 '15 at 2:52
  • @Celada mycommand is actually ffmpeg and it will generally respond by ending the process when using the signal SIGTERM, but perhaps -k is a solution. – BryanK Feb 12 '15 at 3:05
  • for my case I decided to use the the --signal=SIGNAL switch for timeout and set the signal to SIGKILL. – BryanK Feb 12 '15 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.