| 141 |
Kevin |
1 |
/*
|
|
|
2 |
* esh - the 'extensible' shell.
|
|
|
3 |
*
|
|
|
4 |
* Utility functions for system calls.
|
|
|
5 |
*
|
|
|
6 |
* Developed by Godmar Back for CS 3214 Fall 2009
|
|
|
7 |
* Virginia Tech.
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
#include <stdbool.h>
|
|
|
11 |
#include <signal.h>
|
|
|
12 |
|
|
|
13 |
/* Print message to stderr, followed by information about current error.
|
|
|
14 |
* Use like 'printf' */
|
|
|
15 |
void esh_sys_error(char *fmt, ...);
|
|
|
16 |
void esh_sys_fatal_error(char *fmt, ...);
|
|
|
17 |
|
|
|
18 |
/* Get a file descriptor that refers to controlling terminal */
|
|
|
19 |
int esh_sys_tty_getfd(void);
|
|
|
20 |
|
|
|
21 |
/* Initialize tty support.
|
|
|
22 |
* Return pointer to static structure that saves initial state.
|
|
|
23 |
* Restore this state via esh_sys_tty_restore() whenever the shell
|
|
|
24 |
* takes back control of the terminal.
|
|
|
25 |
*/
|
|
|
26 |
struct termios * esh_sys_tty_init(void);
|
|
|
27 |
|
|
|
28 |
/* Save current terminal settings.
|
|
|
29 |
* This function is used when a job is suspended.*/
|
|
|
30 |
void esh_sys_tty_save(struct termios *saved_tty_state);
|
|
|
31 |
|
|
|
32 |
/* Restore terminal to saved settings.
|
|
|
33 |
* This function is used when resuming a suspended job. */
|
|
|
34 |
void esh_sys_tty_restore(struct termios *saved_tty_state);
|
|
|
35 |
|
|
|
36 |
/* Return true if this signal is blocked */
|
|
|
37 |
bool esh_signal_is_blocked(int sig);
|
|
|
38 |
|
|
|
39 |
/* Block a signal. Returns true it was blocked before */
|
|
|
40 |
bool esh_signal_block(int sig);
|
|
|
41 |
|
|
|
42 |
/* Unblock a signal. Returns true it was blocked before */
|
|
|
43 |
bool esh_signal_unblock(int sig);
|
|
|
44 |
|
|
|
45 |
/* Signal handler prototype */
|
|
|
46 |
typedef void (*sa_sigaction_t)(int, siginfo_t *, void *);
|
|
|
47 |
|
|
|
48 |
/* Install signal handler for signal 'sig' */
|
|
|
49 |
void esh_signal_sethandler(int sig, sa_sigaction_t handler);
|