1 /* start.c - Start/stop system services.
3 * Copyright 2016 The Android Open Source Project
5 USE_START(NEWTOY(start, "", TOYFLAG_USR|TOYFLAG_SBIN))
6 USE_STOP(NEWTOY(stop, "", TOYFLAG_USR|TOYFLAG_SBIN))
10 depends on TOYBOX_ON_ANDROID
13 usage: start [SERVICE...]
15 Starts the given system service, or netd/surfaceflinger/zygotes.
19 depends on TOYBOX_ON_ANDROID
22 usage: stop [SERVICE...]
24 Stop the given system service, or netd/surfaceflinger/zygotes.
30 #include <cutils/properties.h>
32 static const char *services[] = {
33 "netd", "surfaceflinger", "zygote", "zygote_secondary", NULL,
36 static void start_stop(int start)
38 const char* property = start ? "ctl.start" : "ctl.stop";
41 if (getuid() != 0) error_exit("must be root");
44 for (i = 0; toys.optargs[i]; i++) property_set(property, toys.optargs[i]);
46 for (i = 0; i < ARRAY_LEN(services); ++i) {
47 property_set(property, services[i]);
50 for (i = ARRAY_LEN(services) - 1; i >= 0; --i) {
51 property_set(property, services[i]);
63 #include "generated/flags.h"