diff options
Diffstat (limited to 'runit')
-rw-r--r-- | runit/runsv.c | 31 | ||||
-rw-r--r-- | runit/sv.c | 22 |
2 files changed, 40 insertions, 13 deletions
diff --git a/runit/runsv.c b/runit/runsv.c index b35c266..1ee3dda 100644 --- a/runit/runsv.c +++ b/runit/runsv.c @@ -61,8 +61,6 @@ static void gettimeofday_ns(struct timespec *ts) /* Compare possibly overflowing unsigned counters */ #define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0) -static int selfpipe[2]; - /* state */ #define S_DOWN 0 #define S_RUN 1 @@ -88,12 +86,27 @@ struct svdir { int fdcontrolwrite; }; -static struct svdir svd[2]; -static smallint sigterm; -static smallint haslog; -static smallint pidchanged = 1; -static int logpipe[2]; -static char *dir; +struct globals { + smallint haslog; + smallint sigterm; + smallint pidchanged; + int selfpipe[2]; + int logpipe[2]; + char *dir; + struct svdir svd[2]; +}; +#define G (*(struct globals*)&bb_common_bufsiz1) +#define haslog (G.haslog ) +#define sigterm (G.sigterm ) +#define pidchanged (G.pidchanged ) +#define selfpipe (G.selfpipe ) +#define logpipe (G.logpipe ) +#define dir (G.dir ) +#define svd (G.svd ) +#define INIT_G() \ + do { \ + pidchanged = 1; \ + } while (0) static void fatal2_cannot(const char *m1, const char *m2) { @@ -434,6 +447,8 @@ int runsv_main(int argc, char **argv) int r; char buf[256]; + INIT_G(); + if (!argv[1] || argv[2]) bb_show_usage(); dir = argv[1]; @@ -158,12 +158,22 @@ Exit Codes #include "libbb.h" #include "runit_lib.h" -static const char *acts; -static char **service; -static unsigned rc; +struct globals { + const char *acts; + char **service; + unsigned rc; /* "Bernstein" time format: unix + 0x400000000000000aULL */ -static uint64_t tstart, tnow; -static svstatus_t svstatus; + uint64_t tstart, tnow; + svstatus_t svstatus; +}; +#define G (*(struct globals*)&bb_common_bufsiz1) +#define acts (G.acts ) +#define service (G.service ) +#define rc (G.rc ) +#define tstart (G.tstart ) +#define tnow (G.tnow ) +#define svstatus (G.svstatus ) +#define INIT_G() do { } while (0) static void fatal_cannot(const char *m1) ATTRIBUTE_NORETURN; @@ -418,6 +428,8 @@ int sv_main(int argc, char **argv) int (*cbk)(const char*); int curdir; + INIT_G(); + xfunc_error_retval = 100; x = getenv("SVDIR"); |