diff options
| author | Roy Marples <roy@marples.name> | 2007-05-14 12:24:18 +0000 | 
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2007-05-14 12:24:18 +0000 | 
| commit | 0942916b729e375df32dae5874c74aaf4f5743a1 (patch) | |
| tree | e02e63aa20ad55047eae69ce2ab63e6f43894a00 | |
| parent | 86c7d44d66a64d923294cf5d830b8fd3bf0e3db1 (diff) | |
| download | openrc-0942916b729e375df32dae5874c74aaf4f5743a1.tar.xz | |
Allow time for pidfiles to be created, #178274.
Use int instead of char for getopt, #178084 thanks to drizztbsd.
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | src/Makefile | 4 | ||||
| -rw-r--r-- | src/fstabinfo.c | 8 | ||||
| -rw-r--r-- | src/mountinfo.c | 8 | ||||
| -rw-r--r-- | src/rc-status.c | 7 | ||||
| -rw-r--r-- | src/runscript.c | 8 | ||||
| -rw-r--r-- | src/start-stop-daemon.c | 32 | 
7 files changed, 46 insertions, 26 deletions
| @@ -1,6 +1,11 @@  # ChangeLog for Gentoo System Intialization ("rc") scripts  # Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2 +  14 May 2007; Roy Marples <uberlord@gentoo.org>: + +    Allow time for pidfiles to be created, #178274. +	Use int instead of char for getopt, #178084 thanks to drizztbsd. +    11 May 2007; Roy Marples <uberlord@gentoo.org>:      Store the defined random pool size, #177722 thanks to Yaroslav Isakov. diff --git a/src/Makefile b/src/Makefile index 4b39bbe3..14cd69f8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -70,7 +70,7 @@ LDLIBS_RS = -ldl  override CPPFLAGS += -D_GNU_SOURCE  endif  ifeq ($(OS),BSD) -override LDLIBS += -lkvm +LDLIBS_LIBRC = -lkvm  endif  HAVE_PAM =  @@ -102,7 +102,7 @@ $(LIBEINFOSO): $(LIBEINFOOBJS)  $(LIBRCOBJS): CFLAGS += -fPIC  $(LIBRCSO): $(LIBRCOBJS)  -	$(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LIBRCOBJS) +	$(CC) -fPIC -shared -Wl,-soname,$(LIBRCSO) -o $(LIBRCSO) $(LDLIBS_LIBRC) $(LIBRCOBJS)  	ln -sf $(LIBRCSO) librc.so  env-update: $(LIBEINFOSO) $(LIBRCSO) env-update.o diff --git a/src/fstabinfo.c b/src/fstabinfo.c index 7ab5b599..15334760 100644 --- a/src/fstabinfo.c +++ b/src/fstabinfo.c @@ -78,15 +78,15 @@ int main (int argc, char **argv)  	int result = EXIT_FAILURE;  	char *token;  	int n = 0; -	char c; +	int opt; -	while ((c = getopt_long (argc, argv, getoptstring, -							 longopts, (int *) 0)) != -1) +	while ((opt = getopt_long (argc, argv, getoptstring, +							   longopts, (int *) 0)) != -1)  	{  #ifdef HAVE_GETMNTENT  		fp = setmntent ("/etc/fstab", "r");  #endif -		switch (c) { +		switch (opt) {  			case 'f':  				while ((token = strsep (&optarg, ",")))  					while ((ent = GET_ENT)) diff --git a/src/mountinfo.c b/src/mountinfo.c index 4699fcd5..b56282f4 100644 --- a/src/mountinfo.c +++ b/src/mountinfo.c @@ -157,11 +157,11 @@ int main (int argc, char **argv)  	bool list_fstype = false;  	bool reverse = false;  	char **mounts = NULL; -	char c; +	int opt; -	while ((c = getopt_long (argc, argv, getoptstring, -							 longopts, (int *) 0)) != -1) -		switch (c) { +	while ((opt = getopt_long (argc, argv, getoptstring, +							   longopts, (int *) 0)) != -1) +		switch (opt) {  			case 'F':  				if (fstype_regex)  					free (fstype_regex); diff --git a/src/rc-status.c b/src/rc-status.c index bf472c1d..358e3439 100644 --- a/src/rc-status.c +++ b/src/rc-status.c @@ -70,13 +70,12 @@ int main (int argc, char **argv)  	char **services = NULL;  	char *level;  	char *service; -	char c; -	int option_index = 0; +	int opt;  	int i;  	int j; -	while ((c = getopt_long(argc, argv, getoptstring, longopts, &option_index)) != -1) -		switch (c) { +	while ((opt = getopt_long(argc, argv, getoptstring, longopts, (int *) 0)) != -1) +		switch (opt) {  			case 'a':  				levels = rc_get_runlevels ();  				break; diff --git a/src/runscript.c b/src/runscript.c index 65f31595..b35474e1 100644 --- a/src/runscript.c +++ b/src/runscript.c @@ -972,7 +972,7 @@ int main (int argc, char **argv)  	bool doneone = false;  	char pid[16];  	int retval; -	char c; +	int opt;  	service = argv[1];  	/* Show help if insufficient args */ @@ -1079,9 +1079,9 @@ int main (int argc, char **argv)  	argv++;  	/* Right then, parse any options there may be */ -	while ((c = getopt_long (argc, argv, getoptstring, -							 longopts, (int *) 0)) != -1) -		switch (c) { +	while ((opt = getopt_long (argc, argv, getoptstring, +							   longopts, (int *) 0)) != -1) +		switch (opt) {  			case 'd':  				setenv ("RC_DEBUG", "yes", 1);  				break; diff --git a/src/start-stop-daemon.c b/src/start-stop-daemon.c index 62973dc6..5e6b8c0a 100644 --- a/src/start-stop-daemon.c +++ b/src/start-stop-daemon.c @@ -500,7 +500,7 @@ int main (int argc, char **argv)  		{ "stderr",       1, NULL, '2'},  		{ NULL,           0, NULL, 0}  	}; -	int c; +	int opt;  	bool start = false;  	bool stop = false;  	bool oknodo = false; @@ -541,10 +541,10 @@ int main (int argc, char **argv)  		if (sscanf (env, "%d", &nicelevel) != 1)  			eerror ("%s: invalid nice level `%s' (SSD_NICELEVEL)", progname, env); -	while ((c = getopt_long (argc, argv, -							 "KN:R:Sbc:d:g:mn:op:qs:tu:r:vx:1:2:", -							 longopts, (int *) 0)) != -1) -		switch (c) { +	while ((opt = getopt_long (argc, argv, +							   "KN:R:Sbc:d:g:mn:op:qs:tu:r:vx:1:2:", +							   longopts, (int *) 0)) != -1) +		switch (opt) {  			case 'K':  /* --stop */  				stop = true;  				break; @@ -962,6 +962,7 @@ int main (int argc, char **argv)  	if (START_WAIT > 0) {  		struct timeval stopat;  		struct timeval now; +		bool retestpid = false;  		if (gettimeofday (&stopat, NULL) != 0)  			eerrorx ("%s: gettimeofday: %s", progname, strerror (errno)); @@ -991,11 +992,20 @@ int main (int argc, char **argv)  				if (kill (pid, 0) == 0)  					alive = true;  			} else { -				if (pidfile && rc_exists (pidfile)) { -					if (do_stop (NULL, NULL, pidfile, uid, 0, true, false, true) > 0) +				if (pidfile) { +					/* The pidfile may not have been written yet - give it some time */ +					if (get_pid (pidfile, true) == -1) {  						alive = true; +						retestpid = true; +					} else { +						retestpid = false; +						if (do_stop (NULL, NULL, pidfile, uid, 0, +									 true, false, true) > 0) +							alive = true; +					}  				} else { -					if (do_stop (exec, cmd, NULL, uid, 0, true, false, true) > 0) +					if (do_stop (exec, cmd, NULL, uid, 0, true, false, true) +						> 0)  						alive = true;  				}  			} @@ -1006,6 +1016,12 @@ int main (int argc, char **argv)  			if (timercmp (&now, &stopat, >))  				break;  		} + +		if (retestpid) { +			if (do_stop (NULL, NULL, pidfile, uid, 0, true, +						 false, true) < 1) +				eerrorx ("%s: %s died", progname, exec); +		}  	}  	if (svcname) | 
