1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

signals: Add init_signals.

This commit is contained in:
Alasdair G Kergon 2014-05-01 20:31:19 +01:00
parent 2eed136f0f
commit 09064cc2db
3 changed files with 20 additions and 15 deletions

View File

@ -33,10 +33,6 @@
static char _lock_dir[PATH_MAX]; static char _lock_dir[PATH_MAX];
static sig_t _oldhandler;
static sigset_t _fullsigset, _intsigset;
static volatile sig_atomic_t _handler_installed;
static void _fin_file_locking(void) static void _fin_file_locking(void)
{ {
release_flocks(1); release_flocks(1);
@ -163,17 +159,8 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd,
if ((access(_lock_dir, R_OK | W_OK | X_OK) == -1) && (errno == EROFS)) if ((access(_lock_dir, R_OK | W_OK | X_OK) == -1) && (errno == EROFS))
return 0; return 0;
if (sigfillset(&_intsigset) || sigfillset(&_fullsigset)) { if (!init_signals(suppress_messages))
log_sys_error_suppress(suppress_messages, "sigfillset", return_0;
"init_file_locking");
return 0;
}
if (sigdelset(&_intsigset, SIGINT)) {
log_sys_error_suppress(suppress_messages, "sigdelset",
"init_file_locking");
return 0;
}
return 1; return 1;
} }

View File

@ -62,6 +62,23 @@ void install_ctrl_c_handler(void)
siginterrupt(SIGINT, 1); siginterrupt(SIGINT, 1);
} }
int init_signals(int suppress_messages)
{
if (sigfillset(&_intsigset) || sigfillset(&_fullsigset)) {
log_sys_error_suppress(suppress_messages, "sigfillset",
"init_signals");
return 0;
}
if (sigdelset(&_intsigset, SIGINT)) {
log_sys_error_suppress(suppress_messages, "sigdelset",
"init_signals");
return 0;
}
return 1;
}
static void _catch_sigint(int unused __attribute__((unused))) static void _catch_sigint(int unused __attribute__((unused)))
{ {
_sigint_caught = 1; _sigint_caught = 1;

View File

@ -18,6 +18,7 @@
void remove_ctrl_c_handler(void); void remove_ctrl_c_handler(void);
void install_ctrl_c_handler(void); void install_ctrl_c_handler(void);
int init_signals(int suppress_messages);
void sigint_allow(void); void sigint_allow(void);
int sigint_caught(void); int sigint_caught(void);