From: Richard Russon Date: Thu, 23 Nov 2017 16:06:13 +0000 (+0000) Subject: standardise the naming of the signal functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34ac0024c2aa91daa8aeb37efeec30248c08fb75;p=neomutt standardise the naming of the signal functions --- diff --git a/compress.c b/compress.c index bd806bb1b..407ee0d20 100644 --- a/compress.c +++ b/compress.c @@ -422,7 +422,7 @@ static int execute_command(struct Context *ctx, const char *command, const char if (!ctx->quiet) mutt_message(progress, ctx->realpath); - mutt_block_signals(); + mutt_sig_block(); endwin(); fflush(stdout); @@ -435,7 +435,7 @@ static int execute_command(struct Context *ctx, const char *command, const char mutt_error(_("Error running \"%s\"!"), sys_cmd); } - mutt_unblock_signals(); + mutt_sig_unblock(); return rc; } diff --git a/conn/socket.c b/conn/socket.c index bf3916962..c8f358ff4 100644 --- a/conn/socket.c +++ b/conn/socket.c @@ -129,7 +129,7 @@ static int socket_connect(int fd, struct sockaddr *sa) if (ConnectTimeout > 0) alarm(ConnectTimeout); - mutt_allow_interrupt(1); + mutt_sig_allow_interrupt(1); /* FreeBSD's connect() does not respect SA_RESTART, meaning * a SIGWINCH will cause the connect to fail. */ @@ -148,7 +148,7 @@ static int socket_connect(int fd, struct sockaddr *sa) if (ConnectTimeout > 0) alarm(0); - mutt_allow_interrupt(0); + mutt_sig_allow_interrupt(0); sigprocmask(SIG_UNBLOCK, &set, NULL); return save_errno; @@ -370,7 +370,7 @@ int raw_socket_read(struct Connection *conn, char *buf, size_t len) { int rc; - mutt_allow_interrupt(1); + mutt_sig_allow_interrupt(1); rc = read(conn->fd, buf, len); if (rc == -1) { @@ -378,7 +378,7 @@ int raw_socket_read(struct Connection *conn, char *buf, size_t len) mutt_sleep(2); SigInt = 0; } - mutt_allow_interrupt(0); + mutt_sig_allow_interrupt(0); if (SigInt) { @@ -403,7 +403,7 @@ int raw_socket_write(struct Connection *conn, const char *buf, size_t count) { int rc; - mutt_allow_interrupt(1); + mutt_sig_allow_interrupt(1); rc = write(conn->fd, buf, count); if (rc == -1) { @@ -411,7 +411,7 @@ int raw_socket_write(struct Connection *conn, const char *buf, size_t count) mutt_sleep(2); SigInt = 0; } - mutt_allow_interrupt(0); + mutt_sig_allow_interrupt(0); if (SigInt) { diff --git a/conn/tunnel.c b/conn/tunnel.c index 99a2f550a..9d58de331 100644 --- a/conn/tunnel.c +++ b/conn/tunnel.c @@ -99,11 +99,11 @@ static int tunnel_socket_open(struct Connection *conn) return -1; } - mutt_block_signals_system(); + mutt_sig_block_system(); pid = fork(); if (pid == 0) { - mutt_unblock_signals_system(0); + mutt_sig_unblock_system(0); devnull = open("/dev/null", O_RDWR); if (devnull < 0 || dup2(pout[0], STDIN_FILENO) < 0 || dup2(pin[1], STDOUT_FILENO) < 0 || dup2(devnull, STDERR_FILENO) < 0) @@ -122,7 +122,7 @@ static int tunnel_socket_open(struct Connection *conn) execle(EXECSHELL, "sh", "-c", Tunnel, NULL, mutt_envlist()); _exit(127); } - mutt_unblock_signals_system(1); + mutt_sig_unblock_system(1); if (pid == -1) { diff --git a/curs_lib.c b/curs_lib.c index 33ddaea91..19b0aa75f 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -134,14 +134,14 @@ struct Event mutt_getch(void) SigInt = 0; - mutt_allow_interrupt(1); + mutt_sig_allow_interrupt(1); #ifdef KEY_RESIZE /* ncurses 4.2 sends this when the screen is resized */ ch = KEY_RESIZE; while (ch == KEY_RESIZE) #endif /* KEY_RESIZE */ ch = getch(); - mutt_allow_interrupt(0); + mutt_sig_allow_interrupt(0); if (SigInt) { diff --git a/filter.c b/filter.c index bef7276e7..2775aeb5d 100644 --- a/filter.c +++ b/filter.c @@ -98,12 +98,12 @@ pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err, } } - mutt_block_signals_system(); + mutt_sig_block_system(); thepid = fork(); if (thepid == 0) { - mutt_unblock_signals_system(0); + mutt_sig_unblock_system(0); if (in) { @@ -152,7 +152,7 @@ pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err, } else if (thepid == -1) { - mutt_unblock_signals_system(1); + mutt_sig_unblock_system(1); if (in) { @@ -212,7 +212,7 @@ int mutt_wait_filter(pid_t pid) int rc; waitpid(pid, &rc, 0); - mutt_unblock_signals_system(1); + mutt_sig_unblock_system(1); rc = WIFEXITED(rc) ? WEXITSTATUS(rc) : -1; return rc; diff --git a/imap/command.c b/imap/command.c index bb3bc0db6..eba868e8e 100644 --- a/imap/command.c +++ b/imap/command.c @@ -1121,11 +1121,11 @@ int imap_exec(struct ImapData *idata, const char *cmdstr, int flags) } /* Allow interruptions, particularly useful if there are network problems. */ - mutt_allow_interrupt(1); + mutt_sig_allow_interrupt(1); do rc = imap_cmd_step(idata); while (rc == IMAP_CMD_CONTINUE); - mutt_allow_interrupt(0); + mutt_sig_allow_interrupt(0); if (rc == IMAP_CMD_NO && (flags & IMAP_CMD_FAIL_OK)) return -2; diff --git a/imap/util.c b/imap/util.c index aed0f85c5..ceaafeb3e 100644 --- a/imap/util.c +++ b/imap/util.c @@ -981,7 +981,7 @@ int imap_wait_keepalive(pid_t pid) sigprocmask(SIG_SETMASK, NULL, &oldmask); sigemptyset(&act.sa_mask); - act.sa_handler = empty_signal_handler; + act.sa_handler = mutt_sig_empty_handler; #ifdef SA_INTERRUPT act.sa_flags = SA_INTERRUPT; #else diff --git a/mbox.c b/mbox.c index 0ad0e8609..456e9606b 100644 --- a/mbox.c +++ b/mbox.c @@ -446,10 +446,10 @@ static int mbox_open_mailbox(struct Context *ctx) mutt_perror(ctx->path); return -1; } - mutt_block_signals(); + mutt_sig_block(); if (mbox_lock_mailbox(ctx, 0, 1) == -1) { - mutt_unblock_signals(); + mutt_sig_unblock(); return -1; } @@ -462,7 +462,7 @@ static int mbox_open_mailbox(struct Context *ctx) mutt_file_touch_atime(fileno(ctx->fp)); mbox_unlock_mailbox(ctx); - mutt_unblock_signals(); + mutt_sig_unblock(); return rc; } @@ -497,7 +497,7 @@ static int mbox_close_mailbox(struct Context *ctx) if (ctx->append) { mutt_file_unlock(ctx->path, fileno(ctx->fp)); - mutt_unblock_signals(); + mutt_sig_unblock(); } mutt_file_fclose(&ctx->fp); @@ -876,10 +876,10 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint) /* lock the file if it isn't already */ if (!ctx->locked) { - mutt_block_signals(); + mutt_sig_block(); if (mbox_lock_mailbox(ctx, 0, 0) == -1) { - mutt_unblock_signals(); + mutt_sig_unblock(); /* we couldn't lock the mailbox, but nothing serious happened: * probably the new mail arrived: no reason to wait till we can * parse it: we'll get it on the next pass @@ -917,7 +917,7 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint) if (unlock) { mbox_unlock_mailbox(ctx); - mutt_unblock_signals(); + mutt_sig_unblock(); } return MUTT_NEW_MAIL; /* signal that new mail arrived */ @@ -942,7 +942,7 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint) if (unlock) { mbox_unlock_mailbox(ctx); - mutt_unblock_signals(); + mutt_sig_unblock(); } return MUTT_REOPENED; } @@ -952,7 +952,7 @@ static int mbox_check_mailbox(struct Context *ctx, int *index_hint) mbox_unlock_mailbox(ctx); mx_fastclose_mailbox(ctx); - mutt_unblock_signals(); + mutt_sig_unblock(); mutt_error(_("Mailbox was corrupted!")); return -1; } @@ -1048,11 +1048,11 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) return -1; } - mutt_block_signals(); + mutt_sig_block(); if (mbox_lock_mailbox(ctx, 1, 1) == -1) { - mutt_unblock_signals(); + mutt_sig_unblock(); mutt_error(_("Unable to lock mailbox!")); goto bail; } @@ -1227,7 +1227,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) fp = fopen(tempfile, "r"); if (!fp) { - mutt_unblock_signals(); + mutt_sig_unblock(); mx_fastclose_mailbox(ctx); mutt_debug(1, "unable to reopen temp copy of mailbox!\n"); mutt_perror(tempfile); @@ -1292,7 +1292,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) snprintf(savefile, sizeof(savefile), "%s/mutt.%s-%s-%u", NONULL(Tmpdir), NONULL(Username), NONULL(ShortHostname), (unsigned int) getpid()); rename(tempfile, savefile); - mutt_unblock_signals(); + mutt_sig_unblock(); mx_fastclose_mailbox(ctx); mutt_pretty_mailbox(savefile, sizeof(savefile)); mutt_error(_("Write failed! Saved partial mailbox to %s"), savefile); @@ -1310,7 +1310,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) if (!ctx->fp) { unlink(tempfile); - mutt_unblock_signals(); + mutt_sig_unblock(); mx_fastclose_mailbox(ctx); mutt_error(_("Fatal error! Could not reopen mailbox!")); FREE(&newOffset); @@ -1332,7 +1332,7 @@ static int mbox_sync_mailbox(struct Context *ctx, int *index_hint) FREE(&newOffset); FREE(&oldOffset); unlink(tempfile); /* remove partial copy of the mailbox */ - mutt_unblock_signals(); + mutt_sig_unblock(); if (option(OPT_CHECK_MBOX_SIZE)) { @@ -1363,7 +1363,7 @@ bail: /* Come here in case of disaster */ /* this is ok to call even if we haven't locked anything */ mbox_unlock_mailbox(ctx); - mutt_unblock_signals(); + mutt_sig_unblock(); FREE(&newOffset); FREE(&oldOffset); diff --git a/mutt/signal.c b/mutt/signal.c index 29cddc230..371192b90 100644 --- a/mutt/signal.c +++ b/mutt/signal.c @@ -25,16 +25,16 @@ * * Signal handling * - * | Function | Description - * | :---------------------------- | :--------------------------------------------------------- - * | default_exit_handler | Notify the user and shutdown gracefully - * | empty_signal_handler | Dummy signal handler - * | mutt_allow_interrupt | Allow/disallow Ctrl-C (SIGINT) - * | mutt_block_signals | Block signals during critical operations - * | mutt_block_signals_system | Block signals before calling exec() - * | mutt_sig_init | Initialise the signal handling - * | mutt_unblock_signals | Restore previously blocked signals - * | mutt_unblock_signals_system | Restore previously blocked signals + * | Function | Description + * | :------------------------- | :--------------------------------------------------------- + * | mutt_sig_exit_handler() | Notify the user and shutdown gracefully + * | mutt_sig_empty_handler() | Dummy signal handler + * | mutt_sig_allow_interrupt() | Allow/disallow Ctrl-C (SIGINT) + * | mutt_sig_block() | Block signals during critical operations + * | mutt_sig_block_system() | Block signals before calling exec() + * | mutt_sig_init() | Initialise the signal handling + * | mutt_sig_unblock() | Restore previously blocked signals + * | mutt_sig_unblock_system() | Restore previously blocked signals */ #include "config.h" @@ -55,26 +55,26 @@ static struct sigaction SysOldQuit; static bool SignalsBlocked; static bool SysSignalsBlocked; -static sig_handler_t sig_handler = empty_signal_handler; -static sig_handler_t exit_handler = default_exit_handler; +static sig_handler_t sig_handler = mutt_sig_empty_handler; +static sig_handler_t exit_handler = mutt_sig_exit_handler; /** - * empty_signal_handler - Dummy signal handler + * mutt_sig_empty_handler - Dummy signal handler * @param sig Signal number, e.g. SIGINT * * Useful for signals that we can't ignore, * or don't want to do anything with. */ -void empty_signal_handler(int sig) +void mutt_sig_empty_handler(int sig) { mutt_debug(2, "Received signal %d\n", sig); } /** - * default_exit_handler - Notify the user and shutdown gracefully + * mutt_sig_exit_handler - Notify the user and shutdown gracefully * @param sig Signal number, e.g. SIGINT */ -void default_exit_handler(int sig) +void mutt_sig_exit_handler(int sig) { #if HAVE_DECL_SYS_SIGLIST printf(_("%s... Exiting.\n"), sys_siglist[sig]); @@ -140,7 +140,7 @@ void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn) /* POSIX doesn't allow us to ignore SIGCHLD, * so we just install a dummy handler for it */ - act.sa_handler = empty_signal_handler; + act.sa_handler = mutt_sig_empty_handler; /* don't need to block any other signals here */ sigemptyset(&act.sa_mask); /* we don't want to mess with stopped children */ @@ -149,12 +149,12 @@ void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn) } /** - * mutt_block_signals - Block signals during critical operations + * mutt_sig_block - Block signals during critical operations * * It's important that certain signals don't interfere with critical operations. - * Call mutt_unblock_signals() to restore the signals' behaviour. + * Call mutt_sig_unblock() to restore the signals' behaviour. */ -void mutt_block_signals(void) +void mutt_sig_block(void) { if (SignalsBlocked) return; @@ -172,9 +172,9 @@ void mutt_block_signals(void) } /** - * mutt_unblock_signals - Restore previously blocked signals + * mutt_sig_unblock - Restore previously blocked signals */ -void mutt_unblock_signals(void) +void mutt_sig_unblock(void) { if (!SignalsBlocked) return; @@ -184,12 +184,12 @@ void mutt_unblock_signals(void) } /** - * mutt_block_signals_system - Block signals before calling exec() + * mutt_sig_block_system - Block signals before calling exec() * * It's important that certain signals don't interfere with the child process. - * Call mutt_unblock_signals_system() to restore the signals' behaviour. + * Call mutt_sig_unblock_system() to restore the signals' behaviour. */ -void mutt_block_signals_system(void) +void mutt_sig_block_system(void) { if (SysSignalsBlocked) return; @@ -210,10 +210,10 @@ void mutt_block_signals_system(void) } /** - * mutt_unblock_signals_system - Restore previously blocked signals + * mutt_sig_unblock_system - Restore previously blocked signals * @param catch If true, restore previous SIGINT, SIGQUIT behaviour */ -void mutt_unblock_signals_system(int catch) +void mutt_sig_unblock_system(int catch) { if (!SysSignalsBlocked) return; @@ -239,12 +239,12 @@ void mutt_unblock_signals_system(int catch) } /** - * mutt_allow_interrupt - Allow/disallow Ctrl-C (SIGINT) + * mutt_sig_allow_interrupt - Allow/disallow Ctrl-C (SIGINT) * @param disposition True to allow Ctrl-C to interrupt signals * * Allow the user to interrupt some long operations. */ -void mutt_allow_interrupt(int disposition) +void mutt_sig_allow_interrupt(int disposition) { struct sigaction sa; diff --git a/mutt/signal2.h b/mutt/signal2.h index c368d76ad..78e842934 100644 --- a/mutt/signal2.h +++ b/mutt/signal2.h @@ -25,13 +25,14 @@ typedef void (*sig_handler_t)(int sig); -void mutt_block_signals(void); -void mutt_unblock_signals(void); -void mutt_block_signals_system(void); -void mutt_unblock_signals_system(int catch); -void default_exit_handler(int sig); -void empty_signal_handler(int sig); void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn); -void mutt_allow_interrupt(int disposition); +void mutt_sig_exit_handler(int sig); +void mutt_sig_empty_handler(int sig); + +void mutt_sig_block(void); +void mutt_sig_unblock(void); +void mutt_sig_block_system(void); +void mutt_sig_unblock_system(int catch); +void mutt_sig_allow_interrupt(int disposition); #endif /* _MUTT_SIGNAL_H */ diff --git a/protos.h b/protos.h index 39ddfdcc3..cbe806e18 100644 --- a/protos.h +++ b/protos.h @@ -147,7 +147,7 @@ void mutt_account_hook(const char *url); void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv); void mutt_adv_mktemp(char *s, size_t l); void mutt_alias_menu(char *buf, size_t buflen, struct Alias *aliases); -void mutt_allow_interrupt(int disposition); +void mutt_sig_allow_interrupt(int disposition); int mutt_body_handler(struct Body *b, struct State *s); int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to); void mutt_buffy(char *s, size_t slen); diff --git a/sendlib.c b/sendlib.c index 70e18a0f5..ea69e2c31 100644 --- a/sendlib.c +++ b/sendlib.c @@ -481,7 +481,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f) else fc = fgetconv_open(fpin, 0, 0, 0); - mutt_allow_interrupt(1); + mutt_sig_allow_interrupt(1); if (a->encoding == ENCQUOTEDPRINTABLE) encode_quoted(fc, f, write_as_text_part(a)); else if (a->encoding == ENCBASE64) @@ -490,7 +490,7 @@ int mutt_write_mime_body(struct Body *a, FILE *f) encode_8bit(fc, f, write_as_text_part(a)); else mutt_file_copy_stream(fpin, f); - mutt_allow_interrupt(0); + mutt_sig_allow_interrupt(0); fgetconv_close(&fc); mutt_file_fclose(&fpin); @@ -2291,7 +2291,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf int fd, st; pid_t pid, ppid; - mutt_block_signals_system(); + mutt_sig_block_system(); sigemptyset(&set); /* we also don't want to be stopped right now */ @@ -2441,7 +2441,7 @@ static int send_msg(const char *path, char **args, const char *msg, char **tempf else st = S_ERR; /* error */ - mutt_unblock_signals_system(1); + mutt_sig_unblock_system(1); return st; } diff --git a/system.c b/system.c index 1d4ee79b0..50b98b7aa 100644 --- a/system.c +++ b/system.c @@ -57,7 +57,7 @@ int mutt_system(const char *cmd) /* must ignore SIGINT and SIGQUIT */ - mutt_block_signals_system(); + mutt_sig_block_system(); act.sa_handler = SIG_DFL; /* we want to restart the waitpid() below */ @@ -74,7 +74,7 @@ int mutt_system(const char *cmd) act.sa_flags = 0; /* reset signals for the child; not really needed, but... */ - mutt_unblock_signals_system(0); + mutt_sig_unblock_system(0); act.sa_handler = SIG_DFL; act.sa_flags = 0; sigemptyset(&act.sa_mask); @@ -96,7 +96,7 @@ int mutt_system(const char *cmd) sigaction(SIGTSTP, &oldtstp, NULL); /* reset SIGINT, SIGQUIT and SIGCHLD */ - mutt_unblock_signals_system(1); + mutt_sig_unblock_system(1); rc = (thepid != -1) ? (WIFEXITED(rc) ? WEXITSTATUS(rc) : -1) : -1;