From 5c00c85fb174dd10ea46a64f9b82e6bbc6c1d2cf Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 8 Aug 2017 14:41:36 +0100 Subject: [PATCH] drop unused param to mutt_system --- mutt.h | 3 --- protos.h | 3 +-- system.c | 67 +++++++------------------------------------------------- 3 files changed, 9 insertions(+), 64 deletions(-) diff --git a/mutt.h b/mutt.h index 75441ed4e..a5bf4ff43 100644 --- a/mutt.h +++ b/mutt.h @@ -79,9 +79,6 @@ struct ListHead; #define MUTT_TOKEN_COMMENT (1<<5) /* don't reap comments */ #define MUTT_TOKEN_SEMICOLON (1<<6) /* don't treat ; as special */ -/* flags for _mutt_system() */ -#define MUTT_DETACH_PROCESS 1 /**< detach subprocess from group */ - /* types for mutt_add_hook() */ #define MUTT_FOLDERHOOK (1 << 0) #define MUTT_MBOXHOOK (1 << 1) diff --git a/protos.h b/protos.h index c137b6688..be6d29eb1 100644 --- a/protos.h +++ b/protos.h @@ -83,8 +83,7 @@ void mutt_make_string_info(char *dst, size_t dstlen, int cols, const char *s, void mutt_free_opts(void); -int _mutt_system(const char *cmd, int flags); -#define mutt_system(x) _mutt_system(x, 0) +int mutt_system(const char *cmd); void mutt_parse_content_type(char *s, struct Body *ct); void mutt_generate_boundary(struct Parameter **parm); diff --git a/system.c b/system.c index 14c01ea31..84ed59d00 100644 --- a/system.c +++ b/system.c @@ -33,13 +33,12 @@ #include #include -int _mutt_system(const char *cmd, int flags) +int mutt_system(const char *cmd) { int rc = -1; struct sigaction act; struct sigaction oldtstp; struct sigaction oldcont; - sigset_t set; pid_t thepid; if (!cmd || !*cmd) @@ -49,64 +48,19 @@ int _mutt_system(const char *cmd, int flags) mutt_block_signals_system(); - /* also don't want to be stopped right now */ - if (flags & MUTT_DETACH_PROCESS) - { - sigemptyset(&set); - sigaddset(&set, SIGTSTP); - sigprocmask(SIG_BLOCK, &set, NULL); - } - else - { - act.sa_handler = SIG_DFL; + act.sa_handler = SIG_DFL; /* we want to restart the waitpid() below */ #ifdef SA_RESTART - act.sa_flags = SA_RESTART; + act.sa_flags = SA_RESTART; #endif - sigemptyset(&act.sa_mask); - sigaction(SIGTSTP, &act, &oldtstp); - sigaction(SIGCONT, &act, &oldcont); - } + sigemptyset(&act.sa_mask); + sigaction(SIGTSTP, &act, &oldtstp); + sigaction(SIGCONT, &act, &oldcont); if ((thepid = fork()) == 0) { act.sa_flags = 0; - if (flags & MUTT_DETACH_PROCESS) - { - int fd; - - /* give up controlling terminal */ - setsid(); - - switch (fork()) - { - case 0: -#ifdef OPEN_MAX - for (fd = 0; fd < OPEN_MAX; fd++) - close(fd); -#elif defined(_POSIX_OPEN_MAX) - for (fd = 0; fd < _POSIX_OPEN_MAX; fd++) - close(fd); -#else - close(0); - close(1); - close(2); -#endif - chdir("/"); - act.sa_handler = SIG_DFL; - sigemptyset(&act.sa_mask); - sigaction(SIGCHLD, &act, NULL); - break; - - case -1: - _exit(127); - - default: - _exit(0); - } - } - /* reset signals for the child; not really needed, but... */ mutt_unblock_signals_system(0); act.sa_handler = SIG_DFL; @@ -126,16 +80,11 @@ int _mutt_system(const char *cmd, int flags) #endif } - if (!(flags & MUTT_DETACH_PROCESS)) - { - sigaction(SIGCONT, &oldcont, NULL); - sigaction(SIGTSTP, &oldtstp, NULL); - } + sigaction(SIGCONT, &oldcont, NULL); + sigaction(SIGTSTP, &oldtstp, NULL); /* reset SIGINT, SIGQUIT and SIGCHLD */ mutt_unblock_signals_system(1); - if (flags & MUTT_DETACH_PROCESS) - sigprocmask(SIG_UNBLOCK, &set, NULL); rc = (thepid != -1) ? (WIFEXITED(rc) ? WEXITSTATUS(rc) : -1) : -1; -- 2.40.0