提交 4921ce08 编写于 作者: R Rich Felker

implement (nonstandard) forkpty

上级 f1ac8a28
......@@ -9,6 +9,7 @@ extern "C" {
#include <sys/ioctl.h>
int openpty(int *, int *, char *, const struct termios *, const struct winsize *);
int forkpty(int *, char *, const struct termios *, const struct winsize *);
#ifdef __cplusplus
extern }
......
#include <pty.h>
#include <unistd.h>
int forkpty(int *m, char *name, const struct termios *tio, const struct winsize *ws)
{
int s;
pid_t pid;
if (openpty(m, &s, name, tio, ws) < 0) return -1;
pid = fork();
if (!pid) {
close(*m);
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
close(s);
return 0;
}
close(s);
if (pid < 0) close(*m);
return pid;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册