Only test crashed services if we can see pid 1.
This commit is contained in:
		@@ -40,3 +40,6 @@ void run_applets(int, char **);
 | 
			
		||||
 | 
			
		||||
/* Handy function so we can wrap einfo around our deptree */
 | 
			
		||||
RC_DEPTREE *_rc_deptree_load (int *);
 | 
			
		||||
 | 
			
		||||
/* Test to see if we can see pid 1 or not */
 | 
			
		||||
bool _rc_findpid1(void);
 | 
			
		||||
 
 | 
			
		||||
@@ -41,9 +41,35 @@
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
extern const char *applet;
 | 
			
		||||
 | 
			
		||||
static bool test_crashed = false;
 | 
			
		||||
static const char *const types_nua[] = { "ineed", "iuse", "iafter", NULL };
 | 
			
		||||
 | 
			
		||||
bool _rc_findpid1(void)
 | 
			
		||||
{
 | 
			
		||||
	RC_PIDLIST *pids;
 | 
			
		||||
	RC_PID *pid;
 | 
			
		||||
	RC_PID *pid2;
 | 
			
		||||
	bool retval = false;
 | 
			
		||||
 | 
			
		||||
	/* If we cannot see process 1, then we don't test to see if
 | 
			
		||||
	 * services crashed or not */
 | 
			
		||||
	pids = rc_find_pids(NULL, NULL, 0, 1);
 | 
			
		||||
	if (pids) {
 | 
			
		||||
		pid = LIST_FIRST(pids);
 | 
			
		||||
		if (pid) {
 | 
			
		||||
			retval = true;
 | 
			
		||||
			while (pid) {
 | 
			
		||||
				pid2 = LIST_NEXT(pid, entries);
 | 
			
		||||
				free(pid);
 | 
			
		||||
				pid = pid2;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		free(pids);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void print_level(char *level)
 | 
			
		||||
{
 | 
			
		||||
	printf ("Runlevel: ");
 | 
			
		||||
@@ -73,7 +99,7 @@ static void print_service(char *service)
 | 
			
		||||
		snprintf(status, sizeof(status), "inactive ");
 | 
			
		||||
		color = ECOLOR_WARN;
 | 
			
		||||
	} else if (state & RC_SERVICE_STARTED) {
 | 
			
		||||
		if (rc_service_daemons_crashed(service))
 | 
			
		||||
		if (test_crashed && rc_service_daemons_crashed(service))
 | 
			
		||||
			snprintf(status, sizeof(status), " crashed ");
 | 
			
		||||
		else {
 | 
			
		||||
			snprintf(status, sizeof(status), " started ");
 | 
			
		||||
@@ -112,7 +138,7 @@ static const char * const longopts_help[] = {
 | 
			
		||||
};
 | 
			
		||||
#include "_usage.c"
 | 
			
		||||
 | 
			
		||||
int rc_status (int argc, char **argv)
 | 
			
		||||
int rc_status(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	RC_DEPTREE *deptree = NULL;
 | 
			
		||||
	RC_STRINGLIST *levels = NULL;
 | 
			
		||||
@@ -125,6 +151,8 @@ int rc_status (int argc, char **argv)
 | 
			
		||||
	int opt;
 | 
			
		||||
	int depopts = RC_DEP_STRICT | RC_DEP_START | RC_DEP_TRACE;
 | 
			
		||||
 | 
			
		||||
	test_crashed = _rc_findpid1();
 | 
			
		||||
 | 
			
		||||
	while ((opt = getopt_long(argc, argv, getoptstring, longopts,
 | 
			
		||||
				  (int *) 0)) != -1)
 | 
			
		||||
		switch (opt) {
 | 
			
		||||
 
 | 
			
		||||
@@ -559,7 +559,7 @@ static RC_SERVICE svc_status(void)
 | 
			
		||||
		snprintf(status, sizeof(status), "inactive");
 | 
			
		||||
		e = &ewarn;
 | 
			
		||||
	} else if (state & RC_SERVICE_STARTED) {
 | 
			
		||||
		if (rc_service_daemons_crashed(service)) {
 | 
			
		||||
		if (_rc_findpid1() && rc_service_daemons_crashed(service)) {
 | 
			
		||||
			snprintf(status, sizeof (status), "crashed");
 | 
			
		||||
			e = &eerror;
 | 
			
		||||
		} else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user