Skip to content

Commit 71bf1dc

Browse files
jfsmigfvennetier
authored andcommitted
Load the SIGKILL delay from the configuration
1 parent 4da651c commit 71bf1dc

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

lib/children.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,22 @@ supervisor_children_set_ids(const gchar *key, gint32 uid, gint32 gid)
11641164
return 0;
11651165
}
11661166

1167+
int
1168+
supervisor_children_set_delay_sigkill(const char *key, time_t delay)
1169+
{
1170+
if (!key) {
1171+
errno = EINVAL;
1172+
return -1;
1173+
}
1174+
struct child_s *sd;
1175+
if (!(sd = supervisor_get_child(key))) {
1176+
errno = ENOENT;
1177+
return -1;
1178+
}
1179+
sd->delay_before_KILL = delay;
1180+
return 0;
1181+
}
1182+
11671183
void
11681184
supervisor_set_callback_postfork(supervisor_postfork_f *cb, void *udata)
11691185
{

lib/gridinit-utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ int supervisor_children_get_info(const gchar *key, struct child_info_s *ci);
241241
*/
242242
int supervisor_children_set_ids(const gchar *key, gint32 uid, gint32 gid);
243243

244+
int supervisor_children_set_delay_sigkill(const char *key, time_t delay);
245+
244246
/* Fork and pipe ----------------------------------------------------------- */
245247

246248
/**

main/gridinit.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,11 +1181,12 @@ _cfg_section_service(GKeyFile *kf, const gchar *section, GError **err)
11811181
gchar *str_command, *str_enabled, *str_startatboot, *str_ondie,
11821182
*str_uid, *str_gid,
11831183
*str_limit_stack, *str_limit_core, *str_limit_fd,
1184-
*str_wd, *str_group;
1184+
*str_wd, *str_group, *str_delay_sigkill;
11851185
gint32 uid, gid;
11861186

11871187
uid = gid = -1;
11881188
str_key = strchr(section, '.') + 1;
1189+
str_delay_sigkill = __get_and_enlist(&gc, kf, section, CFG_KEY_DELAY_KILL);
11891190
str_command = __get_and_enlist(&gc, kf, section, "command");
11901191
str_enabled = __get_and_enlist(&gc, kf, section, "enabled");
11911192
str_ondie = __get_and_enlist(&gc, kf, section, "on_die");
@@ -1322,6 +1323,11 @@ _cfg_section_service(GKeyFile *kf, const gchar *section, GError **err)
13221323
if (str_group)
13231324
supervisor_children_set_group(str_key, str_group);
13241325

1326+
if (str_delay_sigkill) {
1327+
time_t delay = g_ascii_strtoll(str_delay_sigkill, NULL, 10);
1328+
supervisor_children_set_delay_sigkill(str_key, delay);
1329+
}
1330+
13251331
rc = TRUE;
13261332

13271333
label_exit:
@@ -1395,6 +1401,7 @@ _cfg_section_default(GKeyFile *kf, const gchar *section, GError **err)
13951401
gint64 limit_thread_stack = 1024LL * 1024LL;
13961402
gint64 limit_core_size = -1LL;
13971403
gint64 limit_nb_files = 8192LL * 1024LL * 1024LL;
1404+
gint64 delay_sigkill = -1LL;
13981405
gchar **p_key, **keys;
13991406

14001407
keys = g_key_file_get_keys(kf, section, NULL, err);
@@ -1407,10 +1414,13 @@ _cfg_section_default(GKeyFile *kf, const gchar *section, GError **err)
14071414

14081415
str = g_key_file_get_string(kf, section, *p_key, NULL);
14091416

1410-
if (!g_ascii_strcasecmp(*p_key, CFG_KEY_INHERIT)) {
1417+
if (!g_ascii_strcasecmp(*p_key, CFG_KEY_DELAY_KILL)) {
1418+
delay_sigkill = g_ascii_strtoll(str, NULL, 10);
1419+
}
1420+
else if (!g_ascii_strcasecmp(*p_key, CFG_KEY_INHERIT)) {
14111421
inherit_env = g_ascii_strtoll(str, NULL, 10);
14121422
}
1413-
if (!g_ascii_strcasecmp(*p_key, CFG_KEY_LIMIT_CORESIZE)) {
1423+
else if (!g_ascii_strcasecmp(*p_key, CFG_KEY_LIMIT_CORESIZE)) {
14141424
limit_core_size = g_ascii_strtoll(str, NULL, 10) * 1024LL * 1024LL;
14151425
}
14161426
else if (!g_ascii_strcasecmp(*p_key, CFG_KEY_LIMIT_NBFILES)) {
@@ -1507,6 +1517,10 @@ _cfg_section_default(GKeyFile *kf, const gchar *section, GError **err)
15071517
config_subdir = g_strndup(buf_includes, sizeof(buf_includes));
15081518
}
15091519

1520+
if (delay_sigkill >= 0) {
1521+
supervisor_default_delay_KILL = delay_sigkill;
1522+
}
1523+
15101524
return TRUE;
15111525
}
15121526

main/gridinit_internals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
#ifndef __GRIDINIT_INTERNALS_H__
2121
# define __GRIDINIT_INTERNALS_H__ 1
2222

23+
#ifndef CFG_KEY_DELAY_KILL
24+
# define CFG_KEY_DELAY_KILL "delay_sigkill"
25+
#endif
26+
2327
# ifndef GRIDINIT_SOCK_PATH
2428
# define GRIDINIT_SOCK_PATH "/var/run/gridinit.sock"
2529
# endif

0 commit comments

Comments
 (0)