diff --git a/lib/util.h b/lib/util.h index 176d62f56..5b1a1c01c 100644 --- a/lib/util.h +++ b/lib/util.h @@ -149,6 +149,7 @@ int close_error_pipe (int error, const char *text); /* Process spawning */ int my_system (int flags, const char *shell, const char *command); +void my_exit (int status); void save_stop_handler (void); /* Tilde expansion */ diff --git a/lib/utilunix.c b/lib/utilunix.c index c3c670442..dab48f297 100644 --- a/lib/utilunix.c +++ b/lib/utilunix.c @@ -2,7 +2,7 @@ Various utilities - Unix variants Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2007, 2011 + 2004, 2005, 2007, 2011, 2012, 2013 The Free Software Foundation, Inc. Written by: @@ -196,6 +196,21 @@ save_stop_handler (void) sigaction (SIGTSTP, NULL, &startup_handler); } +/* --------------------------------------------------------------------------------------------- */ +/** + * Wrapper for _exit() system call. + * The _exit() function has gcc's attribute 'noreturn', and this is reason why we can't + * mock the call. + * + * @param status exit code + */ + +void +my_exit (int status) +{ + _exit (status); +} + /* --------------------------------------------------------------------------------------------- */ int @@ -253,7 +268,7 @@ my_system (int flags, const char *shell, const char *command) } - _exit (127); /* Exec error */ + my_exit (127); /* Exec error */ } else { diff --git a/src/cons.handler.c b/src/cons.handler.c index a2a283d4a..5797ab8e2 100644 --- a/src/cons.handler.c +++ b/src/cons.handler.c @@ -217,7 +217,7 @@ handle_console_linux (console_action_t action) while (0); mc_global.tty.console_flag = '\0'; status = write (1, &mc_global.tty.console_flag, 1); - _exit (3); + my_exit (3); } /* if (cons_saver_pid ...) */ break; diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 452303ec2..80460f66e 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -3082,7 +3082,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl parent_call ((void *) end_bg_process, ctx, 0); vfs_shut (); - _exit (0); + my_exit (EXIT_SUCCESS); } #endif /* ENABLE_BACKGROUND */ diff --git a/src/subshell.c b/src/subshell.c index c0ba7ec74..70378b2ca 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -241,7 +241,7 @@ init_subshell_child (const char *pty_name) if (tcsetattr (subshell_pty_slave, TCSANOW, &shell_mode)) { fprintf (stderr, "Cannot set pty terminal modes: %s\r\n", unix_error_string (errno)); - _exit (FORK_FAILURE); + my_exit (FORK_FAILURE); } /* Set the pty's size (80x25 by default on Linux) according to the */ @@ -303,7 +303,7 @@ init_subshell_child (const char *pty_name) default: fprintf (stderr, __FILE__ ": unimplemented subshell type %d\r\n", subshell_type); - _exit (FORK_FAILURE); + my_exit (FORK_FAILURE); } /* Attach all our standard file descriptors to the pty */ @@ -351,7 +351,7 @@ init_subshell_child (const char *pty_name) /* If we get this far, everything failed miserably */ g_free (init_file); - _exit (FORK_FAILURE); + my_exit (FORK_FAILURE); } diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index cabf7cdb9..6cac04d7b 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -66,6 +66,7 @@ #include "lib/strescape.h" #include "lib/unixcompat.h" #include "lib/fileloc.h" +#include "lib/util.h" /* my_exit() */ #include "lib/mcconfig.h" #include "src/execute.h" /* pre_exec, post_exec */ @@ -340,7 +341,7 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[]) close (fileset2[0]); close (fileset2[1]); execvp (path, const_cast (char **, argv)); - _exit (3); + my_exit (3); } }