diff options
Diffstat (limited to 'Src/Modules/zpty.c')
-rw-r--r-- | Src/Modules/zpty.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 25ec7dfea..fca0cc172 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -293,8 +293,8 @@ static int newptycmd(char *nam, char *pname, char **args, int echo, int nblock) { Ptycmd p; - int master, slave, pid, oineval = ineval; - char *oscriptname = scriptname; + int master, slave, pid, oineval = ineval, ret; + char *oscriptname = scriptname, syncch; Eprog prog; /* code borrowed from bin_eval() */ @@ -344,6 +344,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) if (get_pty(0, &slave)) exit(1); + SHTTY = slave; + attachtty(mypid); #ifdef TIOCGWINSZ /* Set the window size before associating with the terminal * * so that we don't get hit with a SIGWINCH. I'm paranoid. */ @@ -396,8 +398,23 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) setsparam("TTY", ztrdup(ttystrname)); opts[INTERACTIVE] = 0; + + syncch = 0; + do { + ret = write(1, &syncch, 1); + } while (ret != 1 && ( +#ifdef EWOULDBLOCK + errno == EWOULDBLOCK || +#else +#ifdef EAGAIN + errno == EAGAIN || +#endif +#endif + errno == EINTR)); + execode(prog, 1, 0, "zpty"); stopmsg = 2; + mypid = 0; /* trick to ensure we _exit() */ zexit(lastval, 0); } master = movefd(master); @@ -430,6 +447,18 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) scriptname = oscriptname; ineval = oineval; + do { + ret = read(master, &syncch, 1); + } while (ret != 1 && ( +#ifdef EWOULDBLOCK + errno == EWOULDBLOCK || +#else +#ifdef EAGAIN + errno == EAGAIN || +#endif +#endif + errno == EINTR)); + return 0; } |