diff options
| author | Peter Stephenson <p.stephenson@samsung.com> | 2018-09-06 10:39:45 +0100 |
|---|---|---|
| committer | Peter Stephenson <p.stephenson@samsung.com> | 2018-09-06 10:39:45 +0100 |
| commit | 165000113a869312b9d0920f42d8548a12c4d324 (patch) | |
| tree | 40da47241bb6bdff6bbd42d0a9015512bcd62069 /Src/utils.c | |
| parent | 43372: Add completion for e2label (diff) | |
| download | zsh-165000113a869312b9d0920f42d8548a12c4d324.tar zsh-165000113a869312b9d0920f42d8548a12c4d324.tar.gz zsh-165000113a869312b9d0920f42d8548a12c4d324.tar.bz2 zsh-165000113a869312b9d0920f42d8548a12c4d324.tar.lz zsh-165000113a869312b9d0920f42d8548a12c4d324.tar.xz zsh-165000113a869312b9d0920f42d8548a12c4d324.tar.zst zsh-165000113a869312b9d0920f42d8548a12c4d324.zip | |
43396: Job control debug.
Particularly for TTY ownership.
Diffstat (limited to 'Src/utils.c')
| -rw-r--r-- | Src/utils.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/Src/utils.c b/Src/utils.c index 075d27241..42f6ab773 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2952,7 +2952,7 @@ getquery(char *valid_chars, int purge) int isem = !strcmp(term, "emacs"); struct ttyinfo ti; - attachtty(mypgrp); + ATTACHTTY(mypgrp, 15); gettyinfo(&ti); #ifdef HAS_TIO @@ -4639,13 +4639,21 @@ setcbreak(void) /* give the tty to some process */ -/**/ +/* note: deliberately not automatically prototyped */ mod_export void -attachtty(pid_t pgrp) +attachtty(pid_t pgrp +#ifdef DEBUG_JOB_CONTROL + , int index +#endif + ) { static int ep = 0; if (jobbing && interact) { +#ifdef DEBUG_JOB_CONTROL + fprintf(stderr, "attachtty(%d): pgrp = %d, mypgrp = %d\n", + index, pgrp, mypgrp); +#endif #ifdef HAVE_TCSETPGRP if (SHTTY != -1 && tcsetpgrp(SHTTY, pgrp) == -1 && !ep) #else @@ -4658,8 +4666,11 @@ attachtty(pid_t pgrp) # endif #endif { +#ifdef DEBUG_JOB_CONTROL + fprintf(stderr, "attachtty failed\n"); +#endif if (pgrp != mypgrp && kill(-pgrp, 0) == -1) - attachtty(mypgrp); + ATTACHTTY(mypgrp, 16); else { if (errno != ENOTTY) { @@ -4673,6 +4684,26 @@ attachtty(pid_t pgrp) } } +/**/ +#ifdef DEBUG_JOB_CONTROL + +void set_gleader(int job, int pid, int index) +{ + jobtab[job].gleader = pid; + fprintf(stderr, "set_gleader(%d): %d = %d\n", index, job, pid); +} + +int setpgrp_debug(int pid, int pgid, int index) +{ + int ret = setpgrp(pid, pgid); + fprintf(stderr, "setpgrp(%d): pid %d, pgid %d, current pid %d, ret %d\n", + index, pid, pgid, getpid(), ret); + return ret; +} + +/**/ +#endif /* DEBUG_JOB_CONTROL */ + /* get the process group associated with the tty */ /**/ |
