forked from util-linux/util-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/pty-session: add generic PTY container code
The idea is to consolidate script(1), scriptlive(1) and su(1) --pty and use the same code everywhere. TODO: add callbacks for stdin/out logging (necessary for script(1)). Signed-off-by: Karel Zak <kzak@redhat.com>
- Loading branch information
Showing
4 changed files
with
654 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* This code is in the public domain; do with it what you wish. | ||
* | ||
* Written by Karel Zak <kzak@redhat.com> in Jul 2019 | ||
*/ | ||
#ifndef UTIL_LINUX_PTY_SESSION_H | ||
#define UTIL_LINUX_PTY_SESSION_H | ||
|
||
#include <pty.h> | ||
#include <termios.h> | ||
#include <signal.h> | ||
|
||
struct ul_pty_callbacks { | ||
void (*child_wait)(void *); | ||
void (*child_sigstop)(void *); | ||
}; | ||
|
||
struct ul_pty { | ||
struct termios stdin_attrs; /* stdin and slave terminal runtime attributes */ | ||
int master; /* parent side */ | ||
int slave; /* child side */ | ||
int sigfd; /* signalfd() */ | ||
int poll_timeout; | ||
struct winsize win; /* terminal window size */ | ||
sigset_t orgsig; /* original signal mask */ | ||
|
||
int delivered_signal; | ||
|
||
struct ul_pty_callbacks callbacks; | ||
void *callback_data; | ||
|
||
pid_t child; | ||
|
||
unsigned int isterm:1; /* is stdin terminal? */ | ||
}; | ||
|
||
void ul_pty_init_debug(int mask); | ||
struct ul_pty *ul_new_pty(int is_stdin_tty); | ||
|
||
sigset_t *ul_pty_get_orig_sigset(struct ul_pty *pty); | ||
int ul_pty_get_delivered_signal(struct ul_pty *pty); | ||
|
||
void ul_pty_set_callback_data(struct ul_pty *pty, void *data); | ||
void ul_pty_set_child(struct ul_pty *pty, pid_t child); | ||
|
||
struct ul_pty_callbacks *ul_pty_get_callbacks(struct ul_pty *pty); | ||
int ul_pty_is_running(struct ul_pty *pty); | ||
int ul_pty_setup(struct ul_pty *pty); | ||
void ul_pty_cleanup(struct ul_pty *pty); | ||
void ul_pty_init_slave(struct ul_pty *pty); | ||
int ul_pty_proxy_master(struct ul_pty *pty); | ||
|
||
#endif /* UTIL_LINUX_PTY_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.