Skip to content

Commit

Permalink
exec: Clarify "time_to_kill" behavior
Browse files Browse the repository at this point in the history
Reported by John Quick.

(cherry picked from commit 5bc0c8f)
  • Loading branch information
liviuchircu committed Apr 2, 2018
1 parent adb5605 commit 914431e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
15 changes: 12 additions & 3 deletions modules/exec/README
Expand Up @@ -119,9 +119,18 @@ modparam("exec", "setvars", 1)

1.3.2. time_to_kill (integer)

Specifies the longest time (in seconds) that a program is
allowed to execute. Once this duration is exceeded, the program
is terminated (SIGTERM)
If set, this parameter specifies the longest time (in seconds)
that a program is allowed to execute. Once this duration is
exceeded, the program is terminated (SIGTERM).

NOTE: due to internal limitations, a SIGTERM will actually be
sent to all job pids once the "time_to_kill" expiration timeout
hits. On a standard system, this should have no side-effects,
as pids are monotonically increasing in a slow manner, and
OpenSIPS should run under the "opensips" user, thus rendering
it unable to terminate non-child processes. If this is not the
case on your system, do not use the OpenSIPS "time_to_kill"
feature -- rather implement it within your external app!

Default value is 0 (disabled).

Expand Down
15 changes: 13 additions & 2 deletions modules/exec/doc/exec_admin.xml
Expand Up @@ -133,8 +133,19 @@ modparam("exec", "setvars", 1)
<varname>time_to_kill</varname> (integer)
</title>
<para>
Specifies the longest time (in seconds) that a program is allowed to
execute. Once this duration is exceeded, the program is terminated (SIGTERM)
If set, this parameter specifies the longest time (in seconds) that a
program is allowed to execute. Once this duration is exceeded, the
program is terminated (SIGTERM).
</para>
<para>
NOTE: due to internal limitations, a SIGTERM will actually be sent to
<emphasis role='bold'>all</emphasis> job pids once the "time_to_kill"
expiration timeout hits. On a standard system, this should have no
side-effects, as pids are monotonically increasing in a slow manner,
and OpenSIPS should run under the "opensips" user, thus rendering it
unable to terminate non-child processes. If this is not the case on
your system, do not use the OpenSIPS "time_to_kill" feature -- rather
implement it within your external app!
</para>
<para>
<emphasis>
Expand Down
2 changes: 1 addition & 1 deletion modules/exec/kill.c
Expand Up @@ -106,7 +106,7 @@ static void timer_routine(unsigned int ticks , void * attr)
tmp_tl=ret->next_tl;
ret->next_tl=ret->prev_tl=0;
if (ret->time_out>0) {
LM_INFO("exec timeout, pid %d -> sending SIGTERM\n", ret->pid);
LM_DBG("pid %d -> sending SIGTERM\n", ret->pid);
killr=kill(ret->pid, SIGTERM);
LM_DBG("child process (%d) kill status: %d\n", ret->pid, killr );
}
Expand Down

0 comments on commit 914431e

Please sign in to comment.