Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 175783 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/rc/Makefile (-1 / +1 lines)
Lines 13-19 LINKDIR= ${PREFIX}/${LIBNAME}/${PROG} Link Here
13
BINLINKS=	rc-status
13
BINLINKS=	rc-status
14
SBINLINKS=	rc-service rc-update runscript start-stop-daemon
14
SBINLINKS=	rc-service rc-update runscript start-stop-daemon
15
RC_BINLINKS=	einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
15
RC_BINLINKS=	einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
16
		eindent eoutdent esyslog eval_ecolors \
16
		eindent eoutdent esyslog eval_ecolors ewaitfile \
17
		veinfo vewarn vebegin veend vewend veindent veoutdent \
17
		veinfo vewarn vebegin veend vewend veindent veoutdent \
18
		service_starting service_started \
18
		service_starting service_started \
19
		service_stopping service_stopped \
19
		service_stopping service_stopped \
(-)a/src/rc/rc-applets.c (-3 / +44 lines)
Lines 51-56 Link Here
51
#include "einfo.h"
51
#include "einfo.h"
52
#include "rc-misc.h"
52
#include "rc-misc.h"
53
53
54
/* usecs to wait while we poll the file existance  */
55
#define WAIT_INTERVAL	20000000
56
#define ONE_SECOND      690000000
57
54
/* Applet is first parsed in rc.c - no point in doing it again */
58
/* Applet is first parsed in rc.c - no point in doing it again */
55
extern const char *applet;
59
extern const char *applet;
56
60
Lines 77-82 static int do_e(int argc, char **argv) Link Here
77
	char *p;
81
	char *p;
78
	int level = 0;
82
	int level = 0;
79
	const char *fmt = "%s";
83
	const char *fmt = "%s";
84
	struct timespec ts;
85
	struct timeval stop, now;
80
86
81
	/* Punt applet */
87
	/* Punt applet */
82
	argc--;
88
	argc--;
Lines 97-107 static int do_e(int argc, char **argv) Link Here
97
		if (strcmp(applet, "eend") == 0 ||
103
		if (strcmp(applet, "eend") == 0 ||
98
		    strcmp(applet, "ewend") == 0 ||
104
		    strcmp(applet, "ewend") == 0 ||
99
		    strcmp(applet, "veend") == 0 ||
105
		    strcmp(applet, "veend") == 0 ||
100
		    strcmp(applet, "vweend") == 0)
106
		    strcmp(applet, "vweend") == 0 ||
107
		    strcmp(applet, "ewaitfile") == 0)
101
		{
108
		{
102
			errno = 0;
109
			errno = 0;
103
			retval = (int) strtoimax(argv[0], NULL, 0);
110
			retval = (int)strtoimax(argv[0], &p, 0);
104
			if (errno != 0)
111
			if (!p || *p != '\0')
112
				errno = EINVAL;
113
			if (errno)
105
				retval = EXIT_FAILURE;
114
				retval = EXIT_FAILURE;
106
			else {
115
			else {
107
				argc--;
116
				argc--;
Lines 124-129 static int do_e(int argc, char **argv) Link Here
124
		}
133
		}
125
	}
134
	}
126
135
136
	if (strcmp(applet, "ewaitfile") == 0) {
137
		if (errno)
138
			eerrorx("%s: invalid timeout", applet);
139
		if (argc == 0)
140
			eerrorx("%s: not enough arguments", applet);
141
142
		gettimeofday(&stop, NULL);
143
		stop.tv_sec += retval;
144
		ts.tv_sec = 0;
145
		ts.tv_nsec = WAIT_INTERVAL;
146
		/* retval stores the timeout */
147
		for (i = 0; i < argc; i++) {
148
			ebeginv("Waiting for %s", argv[i]);
149
			for (;;){
150
				if (exists(argv[i]))
151
					break;
152
				if (nanosleep(&ts, NULL) == -1)
153
					return EXIT_FAILURE;
154
				gettimeofday(&now, NULL);
155
				if (retval <= 0)
156
					continue;
157
				if (timercmp(&now, &stop, <))
158
					continue;
159
				eendv(EXIT_FAILURE,
160
				      "timed out waiting for %s", argv[i]);
161
				return EXIT_FAILURE;
162
			}
163
			eendv(EXIT_SUCCESS, NULL);
164
		}
165
		return EXIT_SUCCESS;
166
	}
167
127
	if (argc > 0) {
168
	if (argc > 0) {
128
		for (i = 0; i < argc; i++)
169
		for (i = 0; i < argc; i++)
129
			l += strlen(argv[i]) + 1;
170
			l += strlen(argv[i]) + 1;

Return to bug 175783