@@ -35,6 +35,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
35
35
#include "./gridinit-utils.h"
36
36
#include "./gridinit-internals.h"
37
37
38
+ time_t supervisor_default_delay_KILL = SUPERVISOR_DEFAULT_TIMEOUT_KILL ;
39
+
38
40
static time_t _monotonic_seconds (void ) {
39
41
return g_get_monotonic_time () / G_TIME_SPAN_SECOND ;
40
42
}
@@ -94,6 +96,7 @@ struct my_rlimits_s {
94
96
95
97
struct child_s {
96
98
struct child_s * next ;
99
+ time_t delay_before_KILL ;
97
100
gchar * command ;
98
101
pid_t pid ;
99
102
uid_t uid ;
@@ -103,9 +106,6 @@ struct child_s {
103
106
guint32 user_flags ;
104
107
GSList * env ;
105
108
106
- gchar key [SUPERVISOR_LIMIT_CHILDKEYSIZE ];
107
- gchar group [2048 ];
108
-
109
109
/* Useful stats */
110
110
guint counter_started ;
111
111
guint counter_died ;
@@ -122,17 +122,13 @@ struct child_s {
122
122
123
123
/* Child's startup properties */
124
124
struct my_rlimits_s rlimits ;
125
- };
126
125
127
- static struct child_s SRV_BEACON = {
128
- NULL , NULL , 0 , 0 , 0 ,
129
- NULL , 0 , 0 , NULL ,
130
- "" , "" , /* keys */
131
- 0 , 0 , 0 , 0 , 0 , /* birth/death stats */
132
- {0 ,0 ,0 ,0 ,0 } /* deaths */ ,
133
- {0 ,0 ,0 } /* limits */
126
+ gchar key [SUPERVISOR_LIMIT_CHILDKEYSIZE ];
127
+ gchar group [2048 ];
134
128
};
135
129
130
+ static struct child_s SRV_BEACON = {};
131
+
136
132
static supervisor_postfork_f * supervisor_cb_postfork = NULL ;
137
133
static void * supervisor_cb_postfork_udata = NULL ;
138
134
@@ -465,11 +461,12 @@ _child_stop(struct child_s *sd)
465
461
time_t now = _monotonic_seconds ();
466
462
if (sd -> first_kill_attempt == 0 )
467
463
sd -> first_kill_attempt = now ;
468
- if (sd -> first_kill_attempt > 0 && (now - sd -> first_kill_attempt > SUPERVISOR_DEFAULT_TIMEOUT_KILL )) {
464
+ if (sd -> delay_before_KILL > 0
465
+ && sd -> first_kill_attempt > 0
466
+ && (now - sd -> first_kill_attempt ) > sd -> delay_before_KILL ) {
469
467
DEBUG ("Service [%s] did not exit after 60s, sending SIGKILL" , sd -> key );
470
468
kill (sd -> pid , SIGKILL );
471
- }
472
- else {
469
+ } else {
473
470
DEBUG ("Sending SIGTERM to service [%s] pid %i" , sd -> key , sd -> pid );
474
471
kill (sd -> pid , SIGTERM );
475
472
}
@@ -770,13 +767,11 @@ supervisor_children_fini(void)
770
767
771
768
772
769
gboolean
773
- supervisor_children_register (const gchar * key , const gchar * cmd , GError * * error )
770
+ supervisor_children_register (const gchar * key , const gchar * cmd )
774
771
{
775
772
struct child_s * sd = NULL ;
776
773
777
- (void ) error ;
778
-
779
- /*check if the service is present*/
774
+ /* check if the service is present */
780
775
FOREACH_CHILD (sd ) {
781
776
if (0 == g_ascii_strcasecmp (sd -> key , key )) {
782
777
@@ -790,14 +785,15 @@ supervisor_children_register(const gchar *key, const gchar *cmd, GError **error)
790
785
}
791
786
}
792
787
793
- /*Child not found, it will be created*/
788
+ /* Child not found, it will be created */
794
789
sd = g_try_malloc0 (sizeof (struct child_s ));
795
790
if (NULL == sd ) {
796
791
errno = ENOMEM ;
797
792
return FALSE;
798
793
}
799
794
800
795
g_strlcpy (sd -> key , key , sizeof (sd -> key )- 1 );
796
+ sd -> delay_before_KILL = supervisor_default_delay_KILL ;
801
797
sd -> flags = MASK_STARTED |MASK_RESPAWN |MASK_DELAYED ;
802
798
sd -> working_directory = g_get_current_dir ();
803
799
sd -> command = g_strdup (cmd );
@@ -813,7 +809,7 @@ supervisor_children_register(const gchar *key, const gchar *cmd, GError **error)
813
809
(void ) supervisor_limit_get (SUPERV_LIMIT_MAX_FILES , & (sd -> rlimits .nb_files ));
814
810
(void ) supervisor_limit_get (SUPERV_LIMIT_CORE_SIZE , & (sd -> rlimits .core_size ));
815
811
816
- /*ring insertion*/
812
+ /* ring insertion */
817
813
sd -> next = SRV_BEACON .next ;
818
814
SRV_BEACON .next = sd ;
819
815
0 commit comments