On Thu, Jan 04 2018, Klemens Nanni <k...@posteo.org> wrote:
> A few guards are missing, with this diff ksh compiles cleanly with JOBS
> undefined.
>
> Found while looking for undesired changes after working on job control.
>
> Feedback?

Looks good, ok jca@

I kinda take job control in my shell for granted.  Todd, would it make
sense to just delete the #ifdefs?  I doubt that we'll want to ship a ksh
with no job control in space-constrained installers.

> diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c
> index 53858a37d26..7e29c2f38b8 100644
> --- a/bin/ksh/jobs.c
> +++ b/bin/ksh/jobs.c
> @@ -201,6 +201,7 @@ j_suspend(void)
>  {
>       struct sigaction sa, osa;
>  
> +#ifdef JOBS
>       /* Restore tty and pgrp. */
>       if (ttypgrp_ok) {
>               tcsetattr(tty_fd, TCSADRAIN, &tty_state);
> @@ -218,6 +219,7 @@ j_suspend(void)
>                       }
>               }
>       }
> +#endif /* JOBS */
>  
>       /* Suspend the shell. */
>       memset(&sa, 0, sizeof(sa));
> @@ -228,6 +230,7 @@ j_suspend(void)
>  
>       /* Back from suspend, reset signals, pgrp and tty. */
>       sigaction(SIGTSTP, &osa, NULL);
> +#ifdef JOBS
>       if (ttypgrp_ok) {
>               if (restore_ttypgrp >= 0) {
>                       if (setpgid(0, kshpid) < 0) {
> @@ -246,6 +249,7 @@ j_suspend(void)
>               }
>               tty_init(true);
>       }
> +#endif /* JOBS */
>  }
>  
>  /* job cleanup before shell exit */
> @@ -1050,10 +1054,10 @@ j_waitj(Job *j,
>       j->flags &= ~(JF_WAITING|JF_W_ASYNCNOTIFY);
>  
>       if (j->flags & JF_FG) {
> -             int     status;
> -
>               j->flags &= ~JF_FG;
>  #ifdef JOBS
> +             int     status;
> +
>               if (Flag(FMONITOR) && ttypgrp_ok && j->pgrp) {
>                       /*
>                        * Save the tty's current pgrp so it can be restored
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to