bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trivial bug with number of job slots


From: Risto . Widenius
Subject: Trivial bug with number of job slots
Date: Thu, 27 Jun 2002 16:13:04 +0300

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib -g -O2
uname output: Linux mordva.kotus.fi 2.4.9-21 #1 Thu Jan 17 14:16:30 EST 2002 
i686 unknown
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05a
Patch Level: 0
Release Status: release

Description:

        I encountered what seems to be a minor bug in bash's job
        control on a linux workstation with bash version 2.04.21(1);
        as you can see, I have been able to repeat it with bash 2.05a.

        The bug sometimes prevents foregrounding a job, 'fg' returns
        with the message "no such job" although the job number is
        valid (as checked against the output of 'jobs').

        The bug is triggered when exactly 'job_slots' background jobs
        have been invoked. Invoking one more job and ending it clears
        the situation as 'job_slots' is meanwhile increased by
        'JOB_SLOTS'.

        Initially 'job_slots' will be eight as below, but the bug can
        be repeated for 16 jobs etc.

Repeat-By:

        Start a clean bash:

                mordva$ PS1='\$ ' bash --login --noprofile
                $ 

        Start eight jobs in the background:

                $ more /etc/termcap &
                [1] 24771
                [command repeated 7 times]

        Now we have eight jobs:

                $ jobs
                [1]   Stopped                 more /etc/termcap
                [2]   Stopped                 more /etc/termcap
                [3]   Stopped                 more /etc/termcap
                [4]   Stopped                 more /etc/termcap
                [5]   Stopped                 more /etc/termcap
                [6]   Stopped                 more /etc/termcap
                [7]-  Stopped                 more /etc/termcap
                [8]+  Stopped                 more /etc/termcap
                $ 

        Try to fg job #8:

                $ %8
                bash: fg: %8: no such job
                $ 

Fix:

        I have been able to fix the problem by the following change in
        builtins/common.c:

*** builtins/common.c.orig      Thu Jun 27 15:24:56 2002
--- builtins/common.c   Thu Jun 27 15:26:03 2002
***************
*** 482,488 ****
    if (DIGIT (*word) && all_digits (word))
      {
        job = atoi (word);
!       return (job >= job_slots ? NO_JOB : job - 1);
      }
  
    substring_search = 0;
--- 482,488 ----
    if (DIGIT (*word) && all_digits (word))
      {
        job = atoi (word);
!       return (job > job_slots ? NO_JOB : job - 1);
      }
  
    substring_search = 0;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]