diff options
Diffstat (limited to 'Src/Modules/zpty.c')
-rw-r--r-- | Src/Modules/zpty.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 0ef753915..3c1bef58f 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -331,6 +331,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) /* This code copied from the clone module, except for getting * * the descriptor from get_pty() and duplicating it to 0/1/2. */ + deletehookfunc("exit", ptyhook); clearjobtab(0); ppid = getppid(); mypid = getpid(); @@ -544,7 +545,8 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch) p = dupstring(args[1]); tokenize(p); remnulargs(p); - if (!(prog = patcompile(p, PAT_STATIC, NULL))) { + /* Signals handlers might stomp PAT_STATIC */ + if (!(prog = patcompile(p, PAT_ZDUP, NULL))) { zwarnnam(nam, "bad pattern: %s", args[1]); return 1; } @@ -682,9 +684,14 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch) write_loop(1, buf, used); } - if (seen && (!prog || matchok || !mustmatch)) - return 0; - return cmd->fin + 1; + { + int ret = cmd->fin + 1; + if (seen && (!prog || matchok || !mustmatch)) + ret = 0; + if (prog) + freepatprog(prog); + return ret; + } } static int @@ -846,6 +853,7 @@ bin_zpty(char *nam, char **args, Options ops, UNUSED(int func)) } } +/**/ static int ptyhook(UNUSED(Hookdef d), UNUSED(void *dummy)) { |