So timeout
can be used to set the ultimate time limit on a process / command as mentioned here and here . For example, timeout 300 sleep 1000
will return to prompt after 300 seconds itself instead of 1000.
But is there any way to modify this limit on the fly while process is still running ? So this is what I am looking for.
at time 0 : timeout 300 python long_run.py
at time 250 : <some way to extend the timeout limit by another 300 minutes or so>
I tried following two ways but couldn't make it work.
Through GDB
I tried to attach to timeout
process with gdb. It showed following call stack but I couldn't find a variable whose value I could update to increase time limit.
(gdb) where
#0 0x00007f10b49f6e8c in __libc_waitpid (pid=15753, stat_loc=0x7fff0c799f30, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
#1 0x00000000004022d8 in ?? ()
#2 0x00007f10b4643f45 in __libc_start_main (main=0x401fc0, argc=4, argv=0x7fff0c79a0e8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff0c79a0d8)
at libc-start.c:287
#3 0x0000000000402479 in ?? ()
0 0x00007f10b49f6e8c in __libc_waitpid (pid=15753, stat_loc=0x7fff0c799f30, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:31
31 ../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
(gdb) p *(stat_loc)
$2 = 4204240
Through /proc/
Is there anything we can do in /proc//limits or stat file to update timeout limit for timeout
process or child process.