1 /*
2 Proxy functions for getting access to public variables into 'filemanager' module.
3
4 Copyright (C) 2015-2025
5 Free Software Foundation, Inc.
6
7 Written by:
8 Slava Zanko <slavazanko@gmail.com>, 2015.
9
10 This file is part of the Midnight Commander.
11
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
16
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
26 #include <config.h>
27
28 #include <signal.h> // kill()
29 #include <sys/types.h>
30 #include <sys/wait.h> // waitpid()
31
32 #include "lib/global.h"
33
34 #include "lib/vfs/vfs.h" // vfs_get_raw_current_dir()
35
36 #include "src/setup.h" // quit
37 #include "src/filemanager/filemanager.h" // current_panel
38 #include "src/consaver/cons.saver.h" // handle_console()
39
40 #include "internal.h"
41
42 /*** global variables ****************************************************************************/
43
44 /* path to X clipboard utility */
45
46 /*** file scope macro definitions ****************************************************************/
47
48 /*** file scope type declarations ****************************************************************/
49
50 /*** file scope variables ************************************************************************/
51
52 /* --------------------------------------------------------------------------------------------- */
53 /*** file scope functions ************************************************************************/
54 /* --------------------------------------------------------------------------------------------- */
55
56 /* --------------------------------------------------------------------------------------------- */
57 /*** public functions ****************************************************************************/
58 /* --------------------------------------------------------------------------------------------- */
59
60 const vfs_path_t *
61 subshell_get_cwd (void)
/* ![[previous]](../icons/n_left.png)
![[next]](../icons/right.png)
![[first]](../icons/n_first.png)
![[last]](../icons/last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
62 {
63 // Note: current_panel is NULL during subshell startup
64 if (mc_global.mc_run_mode == MC_RUN_FULL && current_panel != NULL)
65 return current_panel->cwd_vpath;
66
67 return vfs_get_raw_current_dir ();
68 }
69
70 /* --------------------------------------------------------------------------------------------- */
71
72 void
73 subshell_handle_cons_saver (void)
/* ![[previous]](../icons/left.png)
![[next]](../icons/right.png)
![[first]](../icons/first.png)
![[last]](../icons/last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
74 {
75 #ifdef __linux__
76 int status;
77 pid_t pid;
78
79 pid = waitpid (cons_saver_pid, &status, WUNTRACED | WNOHANG);
80
81 if (pid == cons_saver_pid)
82 {
83
84 if (WIFSTOPPED (status))
85 // Someone has stopped cons.saver - restart it
86 kill (pid, SIGCONT);
87 else
88 {
89 // cons.saver has died - disable console saving
90 handle_console (CONSOLE_DONE);
91 mc_global.tty.console_flag = '\0';
92 }
93 }
94 #endif
95 }
96
97 /* --------------------------------------------------------------------------------------------- */
98
99 int
100 subshell_get_mainloop_quit (void)
/* ![[previous]](../icons/left.png)
![[next]](../icons/right.png)
![[first]](../icons/first.png)
![[last]](../icons/last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
101 {
102 return quit;
103 }
104
105 /* --------------------------------------------------------------------------------------------- */
106
107 void
108 subshell_set_mainloop_quit (const int param_quit)
/* ![[previous]](../icons/left.png)
![[next]](../icons/n_right.png)
![[first]](../icons/first.png)
![[last]](../icons/n_last.png)
![[top]](../icons/top.png)
![[bottom]](../icons/bottom.png)
![[index]](../icons/index.png)
*/
109 {
110 quit = param_quit;
111 }
112
113 /* --------------------------------------------------------------------------------------------- */