[Openmcl-devel] where is OS-level feedback stored when launching an external program that does not exist

clayton stanley cstanley at cstanley.no-ip.biz
Tue Apr 17 14:22:09 PDT 2012


Thanks Gary,

Your suggestion works, but I think I need to be more specific with the
request. If you launch a shell process, and that process in turn
launches the executable, then the PID of the lisp-launched process is
that of the shell, yes? This means that another process layer is
introduced using this technique, which I'd rather not do. Also, I
would like to run the same command cross-platform, and if I launch a
shell before launching the executable, I now have to make sure
whatever shell is launched is available on Windows, Linux, and OS X,
etc.

For these reasons, I would like to launch the executable directly from
CCL; no shell layer in between. Thing is, when I do this and the
executable does not exist, the only feedback I get from the process
object is the error code. I was hoping that the OS would give me some
sort of one-liner string feedback, saying that someSpecificExecutable
doesn't exist; much like bash does when you try to launch a
non-existing executable from that shell.

Maybe this information just doesn't exist, and therefore all I have to
go off of in this situation is the exit code. I also think that
another way to ask this question is, how does bash produce that
one-line feedback message when it tries to launch a process that
doesn't exist? does it go off of just the error code, or is there
additional information available that it captures from the os? b/c
what I'm really trying to do is get that same information in the lisp
process.

I also did a bit more troubleshooting, and it turns out that the error
code on linux is 71 in this case. But it's 2 on windows. Which makes
me think that the code is coming from the OS, and not the lisp image.
I also noticed that there are other situations where error code 2 is
used on windows, so I'm now in a situation where I can't really tell
what type of error occurred. If you know of any way to extract more
information from the OS, besides the error code, I'd appreciate
hearing about it.

-Clayton

On Tue, Apr 17, 2012 at 1:00 PM,  <openmcl-devel-request at clozure.com> wrote:
> Send Openmcl-devel mailing list submissions to
>        openmcl-devel at clozure.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://clozure.com/mailman/listinfo/openmcl-devel
> or, via email, send a message with subject or body 'help' to
>        openmcl-devel-request at clozure.com
>
> You can reach the person managing the list at
>        openmcl-devel-owner at clozure.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Openmcl-devel digest..."
>
>
> Today's Topics:
>
>   1.  where is shell output stored when launching an   external
>      program? (clayton stanley)
>   2. Re:  where is shell output stored when launching an external
>      program? (Gary Byers)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 16 Apr 2012 21:00:45 -0400
> From: clayton stanley <cstanley at cstanley.no-ip.biz>
> To: openmcl-devel at clozure.com
> Subject: [Openmcl-devel] where is shell output stored when launching
>        an      external program?
> Message-ID: <3CDCC56E-DACF-4D8E-9E28-04D4E1AAC0D0 at cstanley.no-ip.biz>
> Content-Type: text/plain; charset=us-ascii
>
> I am launching external processes with clozure common lisp. For better feedback/debugging, I would like to display the bash error string when I try to execute a nonexistent binary.
>
> For example:
>
> ? (setf *t* (run-program "programDoesNotExist" '() :output t :error :output :wait nil))
> #<EXTERNAL-PROCESS (programDoesNotExist)[919] (RUNNING) #x302000E6471D>
>
> ? *t*
> #<EXTERNAL-PROCESS (programDoesNotExist)[919] (EXITED : 71) #x302000E6471D>
>
> ? (inspect *t*)
> [0]     #<EXTERNAL-PROCESS (programDoesNotExist)[919] (EXITED : 71) #x302000E6471D>
> [1]     Type: EXTERNAL-PROCESS
> [2]     Class: #<STRUCTURE-CLASS EXTERNAL-PROCESS>
> [3]     PID: 919
> [4]     %STATUS: :EXITED
> [5]     %EXIT-CODE: 71
> [6]     PTY: NIL
> [7]     INPUT: NIL
> [8]     OUTPUT: NIL
> [9]     ERROR: NIL
> [10]    STATUS-HOOK: NIL
> [11]    PLIST: NIL
> [12]    TOKEN: (0)
> [13]    CORE: NIL
> [14]    ARGS: ("programDoesNotExist")
> [15]    SIGNAL: #<SEMAPHORE #x302000E6483D>
> [16]    COMPLETED: #<SEMAPHORE #x302000E647BD>
> [17]    WATCHED-FDS: NIL
> [18]    WATCHED-STREAMS: NIL
> [19]    EXTERNAL-FORMAT: #<EXTERNAL-FORMAT NIL/:UNIX #x30200049FE9D>
> Inspect>
>
> Even with the inspector, I can't find the error information printed by the shell. I'm trying to recover this string in the lisp process:
>
> $ programDoesNotExist
> -bash: programDoesNotExist: command not found
>
> Any help would be greatly appreciated.
>
> Thanks,
> -Clayton
>
> ------------------------------
>
> Message: 2
> Date: Mon, 16 Apr 2012 23:00:46 -0600 (MDT)
> From: Gary Byers <gb at clozure.com>
> To: clayton stanley <cstanley at cstanley.no-ip.biz>
> Cc: openmcl-devel at clozure.com
> Subject: Re: [Openmcl-devel] where is shell output stored when
>        launching an external program?
> Message-ID: <alpine.BSF.2.00.1204162245240.25169 at abq.clozure.com>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> If you'd actually created lisp streams in your example, they'd
> be in the slots named INPUT, OUTPUT, and ERROR (and you could
> read those slots via EXTERNAL-PROCESS-INPUT-STREAM, etc.)
>
> Your example doesn't involve "bash" or any other shell, so I'm
> not sure what it would mean to "display the bash error string"
> in that case.
>
> If you really, really want to see a bash error string, there
> are several ways of doing that.  One way:
>
> ? (run-program "/bin/bash" '("-c" "programDoesNotExist")
>              :output :stream :error :output
>              :wait nil)
> #<EXTERNAL-PROCESS (/bin/bash -c programDoesNotExist)[10513] (RUNNING) #x302000FA698D>
> ? (external-process-output-stream *)
> #<BASIC-CHARACTER-INPUT-STREAM UTF-8 (PIPE/5) #x302000FA65BD>
> ? (read-line *)
> "/bin/bash: programDoesNotExist: command not found"
> NIL
>
> Kind of anticlimactic, isn't it ?
>
> On Mon, 16 Apr 2012, clayton stanley wrote:
>
>> I am launching external processes with clozure common lisp. For better feedback/debugging, I would like to display the bash error string when I try to execute a nonexistent binary.
>>
>> For example:
>>
>> ? (setf *t* (run-program "programDoesNotExist" '() :output t :error :output :wait nil))
>> #<EXTERNAL-PROCESS (programDoesNotExist)[919] (RUNNING) #x302000E6471D>
>>
>> ? *t*
>> #<EXTERNAL-PROCESS (programDoesNotExist)[919] (EXITED : 71) #x302000E6471D>
>>
>> ? (inspect *t*)
>> [0]     #<EXTERNAL-PROCESS (programDoesNotExist)[919] (EXITED : 71) #x302000E6471D>
>> [1]     Type: EXTERNAL-PROCESS
>> [2]     Class: #<STRUCTURE-CLASS EXTERNAL-PROCESS>
>> [3]     PID: 919
>> [4]     %STATUS: :EXITED
>> [5]     %EXIT-CODE: 71
>> [6]     PTY: NIL
>> [7]     INPUT: NIL
>> [8]     OUTPUT: NIL
>> [9]     ERROR: NIL
>> [10]    STATUS-HOOK: NIL
>> [11]    PLIST: NIL
>> [12]    TOKEN: (0)
>> [13]    CORE: NIL
>> [14]    ARGS: ("programDoesNotExist")
>> [15]    SIGNAL: #<SEMAPHORE #x302000E6483D>
>> [16]    COMPLETED: #<SEMAPHORE #x302000E647BD>
>> [17]    WATCHED-FDS: NIL
>> [18]    WATCHED-STREAMS: NIL
>> [19]    EXTERNAL-FORMAT: #<EXTERNAL-FORMAT NIL/:UNIX #x30200049FE9D>
>> Inspect>
>>
>> Even with the inspector, I can't find the error information printed by the shell. I'm trying to recover this string in the lisp process:
>>
>> $ programDoesNotExist
>> -bash: programDoesNotExist: command not found
>>
>> Any help would be greatly appreciated.
>>
>> Thanks,
>> -Clayton
>> _______________________________________________
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
>> http://clozure.com/mailman/listinfo/openmcl-devel
>>
>>
>
>
> ------------------------------
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
> End of Openmcl-devel Digest, Vol 102, Issue 12
> **********************************************



More information about the Openmcl-devel mailing list