Move block_signals/restore_sigmask to utils.c
This commit is contained in:
parent
28c82fe6ee
commit
6e96c4ea68
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: utils.c,v 1.1 2014/01/22 06:14:20 riastradh Exp $ */
|
||||
/* $NetBSD: utils.c,v 1.2 2014/01/22 06:15:04 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: utils.c,v 1.1 2014/01/22 06:14:20 riastradh Exp $");
|
||||
__RCSID("$NetBSD: utils.c,v 1.2 2014/01/22 06:15:04 riastradh Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -39,6 +39,7 @@ __RCSID("$NetBSD: utils.c,v 1.1 2014/01/22 06:14:20 riastradh Exp $");
|
|||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -145,3 +146,19 @@ vwarnx_ss(const char *format, va_list va)
|
|||
(void)write(STDERR_FILENO, buf, strlen(buf));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
block_signals(sigset_t *old_sigmask)
|
||||
{
|
||||
sigset_t block;
|
||||
|
||||
(void)sigfillset(&block);
|
||||
(void)sigprocmask(SIG_BLOCK, &block, old_sigmask);
|
||||
}
|
||||
|
||||
void
|
||||
restore_sigmask(const sigset_t *sigmask)
|
||||
{
|
||||
|
||||
(void)sigprocmask(SIG_SETMASK, sigmask, NULL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: utils.h,v 1.1 2014/01/22 06:14:20 riastradh Exp $ */
|
||||
/* $NetBSD: utils.h,v 1.2 2014/01/22 06:15:04 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
|
@ -47,5 +47,7 @@ void errx_ss(int, const char *, ...) __printflike(2, 3) __dead;
|
|||
void warn_ss(const char *);
|
||||
void warnx_ss(const char *, ...) __printflike(1, 2);
|
||||
void vwarnx_ss(const char *, va_list) __printflike(1, 0);
|
||||
void block_signals(sigset_t *);
|
||||
void restore_sigmask(const sigset_t *);
|
||||
|
||||
#endif /* VNDCOMPRESS_UTILS_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vndcompress.c,v 1.15 2014/01/22 06:14:46 riastradh Exp $ */
|
||||
/* $NetBSD: vndcompress.c,v 1.16 2014/01/22 06:15:04 riastradh Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: vndcompress.c,v 1.15 2014/01/22 06:14:46 riastradh Exp $");
|
||||
__RCSID("$NetBSD: vndcompress.c,v 1.16 2014/01/22 06:15:04 riastradh Exp $");
|
||||
|
||||
#include <sys/endian.h>
|
||||
|
||||
|
@ -101,8 +101,6 @@ static void init_signal_handler(int, const struct sigdesc *, size_t,
|
|||
void (*)(int));
|
||||
static void info_signal_handler(int);
|
||||
static void checkpoint_signal_handler(int);
|
||||
static void block_signals(sigset_t *);
|
||||
static void restore_sigmask(const sigset_t *);
|
||||
static void compress_progress(struct compress_state *);
|
||||
static void compress_init(int, char **, const struct options *,
|
||||
struct compress_state *);
|
||||
|
@ -370,22 +368,6 @@ out:
|
|||
errno = error;
|
||||
}
|
||||
|
||||
static void
|
||||
block_signals(sigset_t *old_sigmask)
|
||||
{
|
||||
sigset_t block;
|
||||
|
||||
(void)sigfillset(&block);
|
||||
(void)sigprocmask(SIG_BLOCK, &block, old_sigmask);
|
||||
}
|
||||
|
||||
static void
|
||||
restore_sigmask(const sigset_t *sigmask)
|
||||
{
|
||||
|
||||
(void)sigprocmask(SIG_SETMASK, sigmask, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Report progress.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue