Article View: comp.emacs
Article #3455Re: process exit status
From: Dr. Hal Levin
Date: Thu, 06 Jun 1991 02:40
Date: Thu, 06 Jun 1991 02:40
51 lines
2397 bytes
2397 bytes
>I'm writing an elisp function that calls a subprocess and waits for
>completion. The obvious way to do this is to use 'call-process', but
>I need the process exit status before the elisp can continue with
>confidence. In all the tests I've run, 'call-process' returns 'nil'
>regardless of the exit status.
>
>Is there a way to obtain the exit status besides resorting to
>'start-process' and using a process-sentinal? The function I'm
>writing shouldn't require such hair, but I *must* have the exit
>status.
This is most assuredly a hack. Nonetheless I offer it because it has a certain
beauty to it - similar to that of well-done "objet-trouvee" art.
(let ((buf (get-buffer-create "*Turnin Error*")))
(set-buffer buf)
(erase-buffer)
(call-process "csh" nil buf nil
"-fc" (concat "compress" " -f" "< " source-file ">!
" target
-file ";if ($status) then\necho ERROR MESSAGE from TURNIN\nelse\necho
OK\nendif"
))
(if (equal (buffer-string) "OK\n")
(progn (kill-buffer buf)
(message "Your File Was Turned In Successfully."))
(progn
(goto-char (point-max))
(princ "
**** E R R O R ****
Your File Was NOT Turned In.
Try Again. But if that doesn't work, check with a TA.
**** BE SURE TO WRITE DOWN THE ERROR MESSAGE AT THE TOP OF THE BUFFER!!! ****"
buf)
(pop-to-buffer buf)
(other-window 1)
(beep)
(message "C-x 1 to remove *Turnin Error* buffer")
))
The idea is simply to force the shell to test the error status and to write to
standard output the result of the test. call-process will place the standard
output in a buffer where the full power of emacs is available to test the
error status.
Technical Details
Message-ID:
<1991Jun6.024016.16503@ncsu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!taco!eos.ncsu.edu!levinReferences:
<WALT.91Jun4110205@arrisun3.utarl.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!taco!eos.ncsu.edu!levin From: levin@eos.ncsu.edu (Dr. Hal Levin) Newsgroups: comp.emacs Subject: Re: process exit status Message-ID: <1991Jun6.024016.16503@ncsu.edu> Date: 6 Jun 91 02:40:16 GMT References: <WALT.91Jun4110205@arrisun3.utarl.edu> Sender: news@ncsu.edu (USENET News System) Reply-To: levin@eos.ncsu.edu (Dr. Hal Levin) Distribution: comp Organization: Project EOS - North Carolina State University Lines: 51