aboutsummaryrefslogtreecommitdiff
path: root/src/librc
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-28 08:42:05 +0000
committerRoy Marples <roy@marples.name>2008-03-28 08:42:05 +0000
commit11e33e81c855395cbd931e99f7452ed6b3fef357 (patch)
tree2af516723abe43f67f38b5419867288913e85169 /src/librc
parent5e8ed2aecabf48895e6d3d090591ffb59fc7588b (diff)
Remove rc_service_start/stop from librc as they block and unmask signals. The application may not wish this behaviour and should fork/exec the service itself.
Diffstat (limited to 'src/librc')
-rw-r--r--src/librc/librc.c89
-rw-r--r--src/librc/librc.h2
-rw-r--r--src/librc/rc.h10
-rw-r--r--src/librc/rc.map2
4 files changed, 0 insertions, 103 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 5d4826c9..13220d2f 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -673,95 +673,6 @@ bool rc_service_value_set(const char *service, const char *option,
}
librc_hidden_def(rc_service_value_set)
-static pid_t _exec_service(const char *service, const char *arg)
-{
- char *file;
- char fifo[PATH_MAX];
- pid_t pid = -1;
- sigset_t full;
- sigset_t old;
- struct sigaction sa;
-
- file = rc_service_resolve(service);
- if (! exists(file)) {
- rc_service_mark(service, RC_SERVICE_STOPPED);
- free(file);
- return 0;
- }
-
- /* We create a fifo so that other services can wait until we complete */
- snprintf(fifo, sizeof(fifo), RC_SVCDIR "/exclusive/%s",
- basename_c(service));
- if (mkfifo(fifo, 0600) != 0 && errno != EEXIST) {
- free(file);
- return -1;
- }
-
- /* We need to block signals until we have forked */
- memset(&sa, 0, sizeof (sa));
- sa.sa_handler = SIG_DFL;
- sigemptyset(&sa.sa_mask);
- sigfillset(&full);
- sigprocmask(SIG_SETMASK, &full, &old);
-
- if ((pid = fork()) == 0) {
- /* Restore default handlers */
- sigaction(SIGCHLD, &sa, NULL);
- sigaction(SIGHUP, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- sigaction(SIGQUIT, &sa, NULL);
- sigaction(SIGTERM, &sa, NULL);
- sigaction(SIGUSR1, &sa, NULL);
- sigaction(SIGWINCH, &sa, NULL);
-
- /* Unmask signals */
- sigprocmask(SIG_SETMASK, &old, NULL);
-
- /* Safe to run now */
- execl(file, file, arg, (char *) NULL);
- fprintf(stderr, "unable to exec `%s': %s\n",
- file, strerror(errno));
- unlink(fifo);
- _exit(EXIT_FAILURE);
- }
-
- if (pid == -1)
- fprintf(stderr, "fork: %s\n",strerror (errno));
-
- sigprocmask(SIG_SETMASK, &old, NULL);
-
- free(file);
-
- return pid;
-}
-
-pid_t rc_service_stop(const char *service)
-{
- RC_SERVICE state = rc_service_state(service);
-
- if (state & RC_SERVICE_FAILED)
- return -1;
-
- if (state & RC_SERVICE_STOPPED)
- return 0;
-
- return _exec_service(service, "stop");
-}
-librc_hidden_def(rc_service_stop)
-
-pid_t rc_service_start(const char *service)
-{
- RC_SERVICE state = rc_service_state(service);
-
- if (state & RC_SERVICE_FAILED)
- return -1;
-
- if (! state & RC_SERVICE_STOPPED)
- return 0;
-
- return _exec_service(service, "start");
-}
-librc_hidden_def(rc_service_start)
bool rc_service_schedule_start(const char *service,
const char *service_to_start)
diff --git a/src/librc/librc.h b/src/librc/librc.h
index b5e9cabd..353b5923 100644
--- a/src/librc/librc.h
+++ b/src/librc/librc.h
@@ -104,8 +104,6 @@ librc_hidden_proto(rc_service_mark)
librc_hidden_proto(rc_service_resolve)
librc_hidden_proto(rc_service_schedule_clear)
librc_hidden_proto(rc_service_schedule_start)
-librc_hidden_proto(rc_service_start)
-librc_hidden_proto(rc_service_stop)
librc_hidden_proto(rc_services_in_runlevel)
librc_hidden_proto(rc_services_in_state)
librc_hidden_proto(rc_services_scheduled)
diff --git a/src/librc/rc.h b/src/librc/rc.h
index 415963b4..04cdba4d 100644
--- a/src/librc/rc.h
+++ b/src/librc/rc.h
@@ -172,16 +172,6 @@ bool rc_service_schedule_clear(const char *);
* @return state of the service */
RC_SERVICE rc_service_state(const char *);
-/*! Start a service
- * @param service to start
- * @return pid of the service starting process */
-pid_t rc_service_start(const char *);
-
-/*! Stop a service
- * @param service to stop
- * @return pid of service stopping process */
-pid_t rc_service_stop(const char *);
-
/*! Check if the service started the daemon
* @param service to check
* @param exec to check
diff --git a/src/librc/rc.map b/src/librc/rc.map
index 845ae946..8a803f3d 100644
--- a/src/librc/rc.map
+++ b/src/librc/rc.map
@@ -32,8 +32,6 @@ global:
rc_service_resolve;
rc_service_schedule_clear;
rc_service_schedule_start;
- rc_service_start;
- rc_service_stop;
rc_services_in_runlevel;
rc_services_in_state;
rc_services_scheduled;