summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-misc.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2003-09-01 18:42:19 +0000
committerColin Watson <cjwatson@debian.org>2003-09-01 18:42:19 +0000
commit8d6b7f4c46de3feb66f704ab483e51ea1a3bb0e1 (patch)
tree41fe3dd71501bbec5b0393f1536c925eaee180e9 /openbsd-compat/bsd-misc.c
parentf045c69060bfdd5cf8759a5f29d7008d02e4de5b (diff)
parent58bfa257481a1c6938ada9bbd38801cc45633fb0 (diff)
Debian release 3.6p1-1.
Diffstat (limited to 'openbsd-compat/bsd-misc.c')
-rw-r--r--openbsd-compat/bsd-misc.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 1c1e43a52..b8e9996d5 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -23,15 +23,20 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26#include "xmalloc.h"
26 27
27RCSID("$Id: bsd-misc.c,v 1.10 2002/07/08 21:09:41 mouring Exp $"); 28RCSID("$Id: bsd-misc.c,v 1.12 2003/03/18 18:21:41 tim Exp $");
28 29
30/*
31 * NB. duplicate __progname in case it is an alias for argv[0]
32 * Otherwise it may get clobbered by setproctitle()
33 */
29char *get_progname(char *argv0) 34char *get_progname(char *argv0)
30{ 35{
31#ifdef HAVE___PROGNAME 36#ifdef HAVE___PROGNAME
32 extern char *__progname; 37 extern char *__progname;
33 38
34 return __progname; 39 return xstrdup(__progname);
35#else 40#else
36 char *p; 41 char *p;
37 42
@@ -42,7 +47,8 @@ char *get_progname(char *argv0)
42 p = argv0; 47 p = argv0;
43 else 48 else
44 p++; 49 p++;
45 return p; 50
51 return xstrdup(p);
46#endif 52#endif
47} 53}
48 54
@@ -129,3 +135,34 @@ setgroups(size_t size, const gid_t *list)
129} 135}
130#endif 136#endif
131 137
138#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
139int nanosleep(const struct timespec *req, struct timespec *rem)
140{
141 int rc, saverrno;
142 extern int errno;
143 struct timeval tstart, tstop, tremain, time2wait;
144
145 TIMESPEC_TO_TIMEVAL(&time2wait, req)
146 (void) gettimeofday(&tstart, NULL);
147 rc = select(0, NULL, NULL, NULL, &time2wait);
148 if (rc == -1) {
149 saverrno = errno;
150 (void) gettimeofday (&tstop, NULL);
151 errno = saverrno;
152 tremain.tv_sec = time2wait.tv_sec -
153 (tstop.tv_sec - tstart.tv_sec);
154 tremain.tv_usec = time2wait.tv_usec -
155 (tstop.tv_usec - tstart.tv_usec);
156 tremain.tv_sec += tremain.tv_usec / 1000000L;
157 tremain.tv_usec %= 1000000L;
158 } else {
159 tremain.tv_sec = 0;
160 tremain.tv_usec = 0;
161 }
162 TIMEVAL_TO_TIMESPEC(&tremain, rem)
163
164 return(rc);
165}
166
167#endif
168