diff options
Diffstat (limited to 'openbsd-compat/bsd-misc.c')
-rw-r--r-- | openbsd-compat/bsd-misc.c | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index 29f6ad38c..3daf61071 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c | |||
@@ -104,16 +104,6 @@ const char *strerror(int e) | |||
104 | } | 104 | } |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | #if !defined(HAVE_STRSIGNAL) | ||
108 | char *strsignal(int sig) | ||
109 | { | ||
110 | static char buf[16]; | ||
111 | |||
112 | (void)snprintf(buf, sizeof(buf), "%d", sig); | ||
113 | return buf; | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | #ifndef HAVE_UTIMES | 107 | #ifndef HAVE_UTIMES |
118 | int utimes(char *filename, struct timeval *tvp) | 108 | int utimes(char *filename, struct timeval *tvp) |
119 | { | 109 | { |
@@ -221,33 +211,6 @@ tcsendbreak(int fd, int duration) | |||
221 | } | 211 | } |
222 | #endif /* HAVE_TCSENDBREAK */ | 212 | #endif /* HAVE_TCSENDBREAK */ |
223 | 213 | ||
224 | mysig_t | ||
225 | mysignal(int sig, mysig_t act) | ||
226 | { | ||
227 | #ifdef HAVE_SIGACTION | ||
228 | struct sigaction sa, osa; | ||
229 | |||
230 | if (sigaction(sig, NULL, &osa) == -1) | ||
231 | return (mysig_t) -1; | ||
232 | if (osa.sa_handler != act) { | ||
233 | memset(&sa, 0, sizeof(sa)); | ||
234 | sigemptyset(&sa.sa_mask); | ||
235 | sa.sa_flags = 0; | ||
236 | #ifdef SA_INTERRUPT | ||
237 | if (sig == SIGALRM) | ||
238 | sa.sa_flags |= SA_INTERRUPT; | ||
239 | #endif | ||
240 | sa.sa_handler = act; | ||
241 | if (sigaction(sig, &sa, NULL) == -1) | ||
242 | return (mysig_t) -1; | ||
243 | } | ||
244 | return (osa.sa_handler); | ||
245 | #else | ||
246 | #undef signal | ||
247 | return (signal(sig, act)); | ||
248 | #endif | ||
249 | } | ||
250 | |||
251 | #ifndef HAVE_STRDUP | 214 | #ifndef HAVE_STRDUP |
252 | char * | 215 | char * |
253 | strdup(const char *str) | 216 | strdup(const char *str) |
@@ -275,7 +238,7 @@ isblank(int c) | |||
275 | pid_t | 238 | pid_t |
276 | getpgid(pid_t pid) | 239 | getpgid(pid_t pid) |
277 | { | 240 | { |
278 | #if defined(HAVE_GETPGRP) && !defined(GETPGRP_VOID) | 241 | #if defined(HAVE_GETPGRP) && !defined(GETPGRP_VOID) && GETPGRP_VOID == 0 |
279 | return getpgrp(pid); | 242 | return getpgrp(pid); |
280 | #elif defined(HAVE_GETPGRP) | 243 | #elif defined(HAVE_GETPGRP) |
281 | if (pid == 0) | 244 | if (pid == 0) |
@@ -319,3 +282,45 @@ llabs(long long j) | |||
319 | return (j < 0 ? -j : j); | 282 | return (j < 0 ? -j : j); |
320 | } | 283 | } |
321 | #endif | 284 | #endif |
285 | |||
286 | #ifndef HAVE_BZERO | ||
287 | void | ||
288 | bzero(void *b, size_t n) | ||
289 | { | ||
290 | (void)memset(b, 0, n); | ||
291 | } | ||
292 | #endif | ||
293 | |||
294 | #ifndef HAVE_RAISE | ||
295 | int | ||
296 | raise(int sig) | ||
297 | { | ||
298 | kill(getpid(), sig); | ||
299 | } | ||
300 | #endif | ||
301 | |||
302 | #ifndef HAVE_GETSID | ||
303 | pid_t | ||
304 | getsid(pid_t pid) | ||
305 | { | ||
306 | errno = ENOSYS; | ||
307 | return -1; | ||
308 | } | ||
309 | #endif | ||
310 | |||
311 | #ifdef FFLUSH_NULL_BUG | ||
312 | #undef fflush | ||
313 | int _ssh_compat_fflush(FILE *f) | ||
314 | { | ||
315 | int r1, r2, r3; | ||
316 | |||
317 | if (f == NULL) { | ||
318 | r2 = fflush(stdout); | ||
319 | r3 = fflush(stderr); | ||
320 | if (r1 == -1 || r2 == -1 || r3 == -1) | ||
321 | return -1; | ||
322 | return 0; | ||
323 | } | ||
324 | return fflush(f); | ||
325 | } | ||
326 | #endif | ||