[Bug 571] New: Fix attached for Job Control bug in ASH shell.

bugzilla at busybox.net bugzilla at busybox.net
Sat Aug 15 19:08:18 UTC 2009


https://bugs.busybox.net/show_bug.cgi?id=571

             Build: busybox 1.13.4-latest
           Summary: Fix attached for Job Control bug in ASH shell.
           Product: Busybox
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P3
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: omattos at gmail.com
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.3


Job control in ASH is broken.

Test script:
# sleep 20 &
# jobs %sle

Expected output:
# sleep 20 &
# jobs %sle
[1] + Running      sleep 20
# _

Actual Output:
# sleep 20 &
# jobs %sle
-sh: jobs: %sle: ambiguous
# _

Cause:
in busybox/shell/ash.c:getjob:

        found = 0;
        while (1) {
                if (!jp)
                        goto err;
                if (match(jp->ps[0].cmd, p)) {
                        if (found)
                                goto err;
                        found = jp;
                        err_msg = "%s: ambiguous";
                }
                jp = jp->prev_job;
        }

Fix:
The above code can NEVER work, because there is no exit from the while loop
even if the correct job is found.  It should be replaced with this:

        found = 0;
        while (jp) {
                if (match(jp->ps[0].cmd, p)) {
                        if (found)
                                goto err;
                        found = jp;
                        err_msg = "%s: ambiguous";
                }
                jp = jp->prev_job;
        }
        if (!found)
                goto err;

Note that it appears err_msg isn't set before going to err, but it is set at
the start of the function.

I'm not a regular around here, so I'll leave this here for someone with commit
access to make this change.


-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list