1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-28 17:10:59 +01:00

31672: Add test that was failing and fix zpty set-up race

This commit is contained in:
Peter Stephenson 2013-08-26 21:01:17 +01:00
parent f61804c4b4
commit b0a0441902
3 changed files with 42 additions and 3 deletions

View file

@ -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() */
@ -398,6 +398,20 @@ 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() */
@ -433,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;
}