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 void start_stop(int start)
34 char *property = start ? "ctl.start" : "ctl.stop";
35 // null terminated in both directions
36 char *services[] = {0,"netd","surfaceflinger","zygote","zygote_secondary",0},
40 if (getuid()) error_exit("must be root");
43 // If we don't have optargs, iterate through services forward/backward.
45 if (!start) ss = services+ARRAY_LEN(services)-2, direction = -1;
48 for (; *ss; ss += direction)
49 if (property_set(property, *ss))
50 error_exit("failed to set property '%s' to '%s'", property, *ss);