minit

A small yet feature-complete init (http://fefe.de/minit/)
Log | Files | Refs | README | LICENSE

commit a4923ac3487a462e36ab5aa48f40bc2e0cde8459
parent ddff1338f2a4c45e72aaa67bdb67b9f1dfb20c06
Author: leitner <leitner>
Date:   Thu, 24 Apr 2003 16:26:45 +0000

add msvc -g (get pid for shell script)

Diffstat:
MCHANGES | 1+
Mminit.c | 3+--
Mmsvc.c | 17++++++++++++++++-
3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -16,6 +16,7 @@ minit now has a heuristic to detect time zone changes and still have msvc report the correct elapsed time since process start/end (don't look at the source code, it's ultra-kludgey) + add msvc -g (get PID for shell scripts) 0.8: call waitpid repeatedly until it returns "no children". diff --git a/minit.c b/minit.c @@ -442,8 +442,7 @@ main(int argc, char *argv[]) { strcat(buf," to "); #endif - if (root[j].pid>1) - root[j].startedat-=diff; + root[j].startedat-=diff; #if 0 i=str_len(buf); diff --git a/msvc.c b/msvc.c @@ -88,7 +88,7 @@ main(int argc,char *argv[]) { int len; if (argc<2) { buffer_putsflush(buffer_1, - "usage: msvc -[uodpchaitkoC] service\n" + "usage: msvc -[uodpchaitkogC] service\n" " msvc -Ppid service\n" " -u\tup; start service with respawn\n" " -o\tonce; start service without respawn\n" @@ -100,6 +100,8 @@ main(int argc,char *argv[]) { " -i\tintr; send SIGINT\n" " -t\tterminate; send SIGTERM\n" " -k\tkill; send SIGKILL\n" + " -g\tget; output just the PID\n" + " -Ppid\tset PID of service (for pidfilehack)\n" " -C\tClear; remove service form active list\n\n"); return 0; } @@ -140,6 +142,19 @@ main(int argc,char *argv[]) { pid_t pid; if (argv[1][0]=='-') { switch (argv[1][1]) { + case 'g': + for (i=2; i<argc; ++i) { + pid=__readpid(argv[i]); + if (pid<2) { + buffer_puts(buffer_2,"msvc: "); + buffer_puts(buffer_2,argv[i]); + buffer_putsflush(buffer_2,pid==1?": service terminated\n":": no such service\n"); + ret=1; + } + buffer_putulong(buffer_1,pid); + buffer_putsflush(buffer_1,"\n"); + } + break; case 'p': sig=SIGSTOP; goto dokill; break; case 'c': sig=SIGCONT; goto dokill; break; case 'h': sig=SIGHUP; goto dokill; break;