Remove the _rc_can_find_pids function

This test to find if we could see pid 1 was being used inconsistently in
rc-status and mark_service_crashed to decide whether we could test to
see if the daemon for the service was crashed, and it was not part of
the librc library.

I am removing it from the executables because of inconsistent usage. I
will add it to the library if it is needed there.
This commit is contained in:
William Hubbs 2018-05-18 16:48:21 -05:00
parent 08da36149c
commit faa8318b3b
4 changed files with 2 additions and 40 deletions

View File

@ -66,9 +66,6 @@ int parse_mode(mode_t *, char *);
/* Handy function so we can wrap einfo around our deptree */
RC_DEPTREE *_rc_deptree_load (int, int *);
/* Test to see if we can see pid 1 or not */
bool _rc_can_find_pids(void);
RC_SERVICE lookup_service_state(const char *service);
void from_time_t(char *time_string, time_t tv);
time_t to_time_t(char *timestring);

View File

@ -68,9 +68,7 @@ int main(int argc, char **argv)
ok = rc_service_started_daemon(service, exec, NULL, idx);
} else if (strcmp(applet, "service_crashed") == 0) {
ok = (_rc_can_find_pids() &&
rc_service_daemons_crashed(service) &&
errno != EACCES);
ok = ( rc_service_daemons_crashed(service) && errno != EACCES);
} else
eerrorx("%s: unknown applet", applet);

View File

@ -411,34 +411,6 @@ RC_DEPTREE * _rc_deptree_load(int force, int *regen)
return rc_deptree_load();
}
bool _rc_can_find_pids(void)
{
RC_PIDLIST *pids;
RC_PID *pid;
RC_PID *pid2;
bool retval = false;
if (geteuid() == 0)
return true;
/* 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 const struct {
const char * const name;
RC_SERVICE bit;

View File

@ -54,7 +54,6 @@ const char *usagestring = "" \
"Usage: rc-status [options] <runlevel>...\n" \
" or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]";
static bool test_crashed = false;
static RC_DEPTREE *deptree;
static RC_STRINGLIST *types;
@ -145,9 +144,7 @@ print_service(const char *service)
color = ECOLOR_WARN;
} else if (state & RC_SERVICE_STARTED) {
errno = 0;
if (test_crashed &&
rc_service_daemons_crashed(service) &&
errno != EACCES)
if (rc_service_daemons_crashed(service) && errno != EACCES)
{
child_pid = rc_service_value_get(service, "child_pid");
start_time = rc_service_value_get(service, "start_time");
@ -240,8 +237,6 @@ int main(int argc, char **argv)
char *p, *runlevel = NULL;
int opt, retval = 0;
test_crashed = _rc_can_find_pids();
applet = basename_c(argv[0]);
while ((opt = getopt_long(argc, argv, getoptstring, longopts,
(int *) 0)) != -1)