|
C-Menu 0.2.9
A User Interface Toolkit
|
This module provides functions to execute external commands. More...
Functions | |
| int | dmon (char **eargv) |
| Fork and execute a command as a daemon. | |
| int | fork_exec (char **argv) |
| Fork and exec a command. | |
| int | full_screen_fork_exec (char **argv) |
| Execute a command in full screen mode. | |
| int | full_screen_shell (char *shellCmdPtr) |
| Execute a shell command in full screen mode. | |
| int | shell (char *shellCmdPtr) |
| Execute a shell command. | |
This module provides functions to execute external commands.
Handles terminal settings, signal handling, and error reporting to ensure a smooth user experience when executing commands from within the application. The main functions include full_screen_fork_exec, full_screen_shell, and fork_exec, which manage the execution of commands while maintaining the integrity of the application's user interface.
| int dmon | ( | char ** | eargv | ) |
Fork and execute a command as a daemon.
| eargv | - array of arguments for the command to execute |
Forks the process twice to create a daemon. Sets the session ID and working directory. Redirects standard file descriptors to /dev/null. Closes all open file descriptors. Executes the command using execvp. Exits with failure if any step fails.
Definition at line 226 of file exec.c.
References capture_curses_tioctl(), restore_curses_tioctl(), restore_wins(), sig_dfl_mode(), and sig_prog_mode().
Referenced by menu_cmd_processor().
| int fork_exec | ( | char ** | argv | ) |
Fork and exec a command.
| argv | - array of arguments for the command to execute |
Captures and restores terminal settings around the fork and exec. Sets signal handlers to default in the child process. Waits for the child process to complete in the parent process. Handles errors from fork and execvp, and reports child exit status. Restores curses mode and keypad settings after execution. Restores window states after execution. Uses a temporary string buffer tmp_str for error messages. Uses Perror for error reporting. Uses sig_dfl_mode and sig_prog_mode for signal handling. Uses capture_curses_tioctl and restore_curses_tioctl for terminal settings. Uses restore_shell_tioctl for shell terminal settings. Uses waitpid to wait for the child process. Uses WIFEXITED, WEXITSTATUS, WIFSIGNALED, and WTERMSIG to interpret child status. Uses keypad to manage keypad mode in curses. Uses restore_wins to restore window states. Uses errno for error codes. Uses pid_t for process IDs. Uses standard file descriptors STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO. Uses execvp for executing the command. Uses fork for creating a new process. Uses ssnprintf for formatting error messages. Uses switch-case for handling fork results. Uses default shell if SHELL environment variable is not set.
Prevent child process from writing to terminal
Definition at line 130 of file exec.c.
References capture_curses_tioctl(), Perror(), restore_curses_tioctl(), restore_shell_tioctl(), restore_wins(), sig_dfl_mode(), sig_prog_mode(), and ssnprintf().
Referenced by full_screen_fork_exec(), and shell().
| int full_screen_fork_exec | ( | char ** | argv | ) |
Execute a command in full screen mode.
| argv | - array of arguments for the command to execute |
Clear the screen, move the cursor to the bottom, and refresh the screen before executing the command. After the command completes, clear the screen, move the cursor to the top, refresh the screen, and restore the windows.
Definition at line 46 of file exec.c.
References fork_exec().
Referenced by menu_cmd_processor().
| int full_screen_shell | ( | char * | shellCmdPtr | ) |
Execute a shell command in full screen mode.
| shellCmdPtr | - pointer to the shell command string |
Clear the screen, move the cursor to the top, and refresh the screen before executing the shell command. After the command completes, restore the windows.
Definition at line 62 of file exec.c.
References restore_wins(), and shell().
Referenced by menu_cmd_processor(), and view_cmd_processor().
| int shell | ( | char * | shellCmdPtr | ) |
Execute a shell command.
| shellCmdPtr | - pointer to the shell command string |
Executes the command string using the user's shell. If the SHELL environment variable is not set, use /bin/sh.
Definition at line 82 of file exec.c.
References fork_exec().
Referenced by form_exec_cmd(), full_screen_shell(), lp(), and view_cmd_processor().