Steel Bank Common Lisp

Distinguish program not found from program exited with status 1 in sb-ext:run-program

Reported by Zach Beane on 2010-11-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

I'm using SBCL 1.0.44+ on Linux/AMD64.

I don't think there is a way to distinguish two kinds of run-program results: the specified program exists and exits with exit code 1, and the specified program does not exist. For example:

    * (describe (sb-ext:run-program "/bin/false" nil))
    #<SB-IMPL::PROCESS :EXITED 1>
      [structure-object]

    Slots with :INSTANCE allocation:
      PID = 20023
      %STATUS = :EXITED
      EXIT-CODE = 1
      CORE-DUMPED = NIL
      PTY = NIL
      INPUT = NIL
      OUTPUT = NIL
      ERROR = NIL
      STATUS-HOOK = NIL
      PLIST = NIL
      COOKIE = (0)
    ; No value

    * (describe (sb-ext:run-program "/nobin/no-such-program" nil))
    #<SB-IMPL::PROCESS :EXITED 1>
      [structure-object]

    Slots with :INSTANCE allocation:
      PID = 20026
      %STATUS = :EXITED
      EXIT-CODE = 1
      CORE-DUMPED = NIL
      PTY = NIL
      INPUT = NIL
      OUTPUT = NIL
      ERROR = NIL
      STATUS-HOOK = NIL
      PLIST = NIL
      COOKIE = (0)
    ; No value

I would prefer to get an error in the latter code, or at least have some part of the structure make it clear that the program to run was not found.

Changed in sbcl:
importance: Undecided → Medium
status: New → Triaged
Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: Triaged → In Progress
Nikodemus Siivola (nikodemus) wrote :

commit 6cfdd9e66519b513e0935c410fbb30fc880efb61
Author: Nicolas Edel <email address hidden>
Date: Fri Nov 18 12:49:22 2011 +0200

    pass errno from exec() to parent in spawn()

      Open a pipe, set FD_CLOEXEC.

      Child: if exec() fails, grab errno and write it to pipe.

      Parent: try to read from the pipe -- if you get something, it means the
      child didn't exec and the reason is in the pipe. Wait for the child to exit
      and return -1 and set errno to whatever the child got.

      Also use _exit() instead of exit() when dying in the child after exec
      failure -- running exit hooks there would probably be bad.

      (Somewhat edited from Nicolas' original patch.)

    Signed-off-by: Nikodemus Siivola <email address hidden>

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers