terminal-util: introduce openpt_allocate()

Allocating a pty is done in a couple of places so let's introduce a new helper
which does the job.

Also the new function, as well as openpt_in_namespace(), returns both pty
master and slave so the callers don't need to know about the pty slave
allocation details.

For the same reasons machine_openpt() prototype has also been changed to return
both pty master and slave so callers don't need to allocate a pty slave which
might be in a different namespace.

Finally openpt_in_namespace() has been renamed into
openpt_allocate_in_namespace().
This commit is contained in:
Franck Bui
2019-06-18 09:26:31 +02:00
parent 3acc84ebd9
commit ae1d13db05
5 changed files with 55 additions and 45 deletions
+2 -2
View File
@@ -151,9 +151,9 @@ int getttyname_malloc(int fd, char **r);
int getttyname_harder(int fd, char **r);
int ptsname_malloc(int fd, char **ret);
int ptsname_namespace(int pty, char **ret);
int openpt_in_namespace(pid_t pid, int flags);
int openpt_allocate(int flags, char **ret_slave);
int openpt_allocate_in_namespace(pid_t pid, int flags, char **ret_slave);
int open_terminal_in_namespace(pid_t pid, const char *name, int mode);
int vt_default_utf8(void);