@@ -126,26 +126,19 @@ compare_child_info(gconstpointer p1, gconstpointer p2)
126
126
}
127
127
128
128
static const char *
129
- get_child_status (struct child_info_s * ci , gboolean * faulty )
129
+ get_child_status (struct child_info_s * ci , struct keyword_set_s * kw )
130
130
{
131
- struct keyword_set_s * kw ;
132
-
133
- kw = flag_color ? & KEYWORDS_COLOR : & KEYWORDS_NORMAL ;
134
131
135
132
if (ci -> broken ) {
136
- * faulty = TRUE;
137
133
return kw -> broken ;
138
134
}
139
135
if (!ci -> enabled ) {
140
- * faulty = FALSE;
141
136
return kw -> disabled ;
142
137
}
143
138
if (ci -> pid <= 0 ) {
144
- * faulty = TRUE;
145
139
return kw -> down ;
146
140
}
147
141
148
- * faulty = FALSE;
149
142
return kw -> up ;
150
143
}
151
144
@@ -421,27 +414,30 @@ command_status(int lvl, int argc, char **args)
421
414
break ;
422
415
}
423
416
424
- int count_faulty = 0 , count_all = 0 , count_misses = 0 ;
417
+ int count_misses = 0 , count_broken = 0 , count_down = 0 ;
418
+ struct keyword_set_s * kw ;
419
+ kw = flag_color ? & KEYWORDS_COLOR : & KEYWORDS_NORMAL ;
425
420
426
421
/* iterate on the lines */
427
422
for (GList * l = jobs ; l ;l = l -> next ) {
428
423
char str_time [20 ] = "---------- --------" ;
429
424
const char * str_status = "-" ;
430
425
struct child_info_s * ci = NULL ;
431
- gboolean faulty = FALSE;
432
426
433
427
ci = l -> data ;
434
428
435
429
/* Prepare some fields */
436
430
if (ci -> pid > 0 )
437
431
strftime (str_time , sizeof (str_time ), "%Y-%m-%d %H:%M:%S" ,
438
432
gmtime (& (ci -> last_start_attempt )));
439
- str_status = get_child_status (ci , & faulty );
433
+ str_status = get_child_status (ci , kw );
440
434
441
435
/* Manage counters */
442
- if (faulty )
443
- count_faulty ++ ;
444
- count_all ++ ;
436
+
437
+ if (str_status == kw -> down )
438
+ count_down ++ ;
439
+ if (str_status == kw -> broken )
440
+ count_broken ++ ;
445
441
446
442
/* Print now! */
447
443
switch (lvl ) {
@@ -475,7 +471,16 @@ command_status(int lvl, int argc, char **args)
475
471
g_list_free_full (all_jobs , (GDestroyNotify )child_info_free );
476
472
g_list_free (jobs );
477
473
478
- return !(!count_misses && !count_faulty && (!argc || count_all > 0 ));
474
+ int rc = 0 ;
475
+
476
+ if (count_down )
477
+ rc |= 1 ;
478
+ if (count_misses )
479
+ rc |= 2 ;
480
+ if (count_broken )
481
+ rc |= 4 ;
482
+
483
+ return rc ;
479
484
}
480
485
481
486
static int
0 commit comments