[prev in list] [next in list] [prev in thread] [next in thread]
List: sbcl-devel
Subject: Re: [Sbcl-devel] help with sb-ext:run-program
From: MH-Freiburg <rm () mh-freiburg ! de>
Date: 2017-05-30 10:57:53
Message-ID: 543822A6-4FC2-4135-888A-855C34B49B66 () mh-freiburg ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> On 30 May 2017, at 12:45, Jim Newton <jimka.issy@gmail.com> wrote:
>
> Does anyone think my expectation is reasonable that with-output-to-string should \
> return the string containing the printed output of the program, be it "ls -l" or \
> otherwise? Or am I misunderstanding something fundamental here?
I think your expectation is correct, I just tested your "ls -l" snippets and
it works as expected here (Debian GNU/Linux)
Cheers, Ralf Mattes
>
> > On Tue, May 30, 2017 at 10:59 AM, Jim Newton <jimka.issy@gmail.com> wrote:
> > when I replace the call to vmmap with a call to ls, it get even stranger results. \
> >
> > (let ((string (with-output-to-string (str)
> > (sb-ext:run-program "ls" (list "-l")
> > > search t
> > > wait t
> > > output str))))
> > string)
> >
> > non-empty buffer when EOF reached while reading from child: #(80
> > 114
> > 111
> > 99
> > 101
> > 115
> > 115
> > 58
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 115
> > 98
> > 99
> > 108
> > 32
> > 91
> > 49
> > 49
> > 50
> > 51
> > 93
> > 10
> > 80
> > 97
> > 116
> > 104
> > 58
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 47
> > 117
> > 115
> > 114
> > 47
> > 108
> > 111
> > 99
> > 97
> > 108
> > 47
> > 98
> > 105
> > 110
> > 47
> > 115
> > 98
> > 99
> > 108
> > 10
> > 76
> > 111
> > 97
> > 100
> > 32
> > 65
> > 100
> > 100
> > 114
> > 101
> > 115
> > 115
> > 58
> > 32
> > 32
> > 32
> > 32
> > 48
> > 120
> > 49
> > 48
> > 48
> > 48
> > 48
> > 48
> > 10
> > 73
> > 100
> > 101
> > 110
> > 116
> > 105
> > 102
> > 105
> > 101
> > 114
> > 58
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 115
> > 98
> > 99
> > 108
> > 10
> > 86
> > 101
> > 114
> > 115
> > 105
> > 111
> > 110
> > 58
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 63
> > 63
> > 63
> > 10
> > 67
> > 111
> > 100
> > 101
> > 32
> > 84
> > 121
> > 112
> > 101
> > 58
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 88
> > 56
> > 54
> > 45
> > 54
> > 52
> > 10
> > 80
> > 97
> > 114
> > 101
> > 110
> > 116
> > 32
> > 80
> > 114
> > 111
> > 99
> > 101
> > 115
> > 115
> > 58
> > 32
> > 32
> > 69
> > 109
> > 97
> > 99
> > 115
> > 45
> > 120
> > 56
> > 54
> > 95
> > 54
> > 52
> > 45
> > 49
> > 48
> > 95
> > 57
> > 32
> > 91
> > 49
> > 48
> > 55
> > 55
> > 93
> > 10
> > 10
> > 68
> > 97
> > 116
> > 101
> > 47
> > 84
> > 105
> > 109
> > 101
> > 58
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 32
> > 50
> > 48
> > 49
> > 55
> > 45
> > 48
> > 53
> > 45
> > 51
> > 48
> > 32
> > 49
> > 48
> > 58
> > 52
> > 48
> > 58
> > 48
> > 55
> > 46
> > 50
> > 53
> > 57
> > 32
> > 43
> > 48
> > 50
> > 48
> > 48
> > 10
> > 76
> > 97
> > 117
> > 110
> > 99
> > 104
> > 32)
> > [Condition of type SIMPLE-ERROR]
> >
> > Restarts:
> > 0: [REMOVE-FD-HANDLER] Remove #<SB-IMPL::HANDLER INPUT on descriptor 20: \
> > #<CLOSURE (LAMBDA (SB-IMPL::FD) :IN SB-IMPL::COPY-DESCRIPTOR-TO-STREAM) \
> > {100822BDEB}>>
> > 1: [RETRY] Retry SLIME REPL evaluation request.
> > 2: [*ABORT] Return to SLIME's top level.
> > 3: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {1007C34E53}>)
> >
> > Backtrace:
> > 0: ((LAMBDA (SB-IMPL::FD) :IN SB-IMPL::COPY-DESCRIPTOR-TO-STREAM) #<unavailable \
> > argument>)
> > 1: (SB-IMPL::SUB-SUB-SERVE-EVENT 1 0)
> > 2: (SB-IMPL::SUB-SERVE-EVENT 1 0 NIL)
> > 3: (SB-SYS:SERVE-ALL-EVENTS 1)
> > 4: (PROCESS-WAIT #<SB-IMPL::PROCESS 3534 :RUNNING> NIL)
> > 5: ((FLET #:CLEANUP-FUN-1419 :IN RUN-PROGRAM)) [cleanup]
> > 6: (RUN-PROGRAM "ls" ("-l") :ENV NIL :ENVIRONMENT NIL :WAIT T :SEARCH T :PTY NIL \
> > :INPUT NIL :IF-INPUT-DOES-NOT-EXIST NIL :OUTPUT #<SB-IMPL::STRING-OUTPUT-STREAM \
> > {10083C5EB3}> :IF-OUTPUT-EXISTS :ERROR :ER..
> > 7: ((LAMBDA ()))
> > 8: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LET ((STRING #)) STRING) #<NULL-LEXENV>)
> > 9: (EVAL (LET ((STRING #)) STRING))
> > 10: (SWANK::EVAL-REGION "(let ((string (with-output-to-string (str) ..)
> > 11: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
> > 12: (SWANK-REPL::TRACK-PACKAGE #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) \
> > {10082EFEFB}>)
> > 13: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
> > 14: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation request." \
> > #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {10082EFE5B}>)
> > 15: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
> > 16: (SWANK/BACKEND:CALL-WITH-SYNTAX-HOOKS #<CLOSURE (LAMBDA NIL :IN \
> > SWANK-REPL::REPL-EVAL) {10082EFE3B}>)
> > 17: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA NIL :IN \
> > SWANK-REPL::REPL-EVAL) {10082EFE3B}>)
> > 18: (SWANK-REPL::REPL-EVAL "(let ((string (with-output-to-string (str) ..)
> > 19: (SWANK-REPL:LISTENER-EVAL "(let ((string (with-output-to-string (str) ..)
> > 20: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK-REPL:LISTENER-EVAL "(let ((string \
> > (with-output-to-string (str) ..)
> > 21: (EVAL (SWANK-REPL:LISTENER-EVAL "(let ((string (with-output-to-string (str) \
> > ..)
> > 22: (SWANK:EVAL-FOR-EMACS (SWANK-REPL:LISTENER-EVAL "(let ((string \
> > (with-output-to-string (str) ..)
> > 23: (SWANK::PROCESS-REQUESTS NIL)
> > 24: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
> > 25: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
> > 26: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> \
> > #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {1007E4002B}>)
> > 27: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN \
> > "/Users/jnewton/sw/slime/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> \
> > #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {1007E4002B}>)
> > 28: (SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> \
> > #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {1007E4002B}>)
> > 29: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
> > 30: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . \
> > #1=#<SWANK/GRAY::SLIME-INPUT-STREAM {10030AA0A3}>) (*STANDARD-OUTPUT* . \
> > #2=#<SWANK/GRAY::SLIME-OUTPUT-STREAM {10031B2A83}>) (*TRACE-OUTPUT* . #2#) \
> > (*ERR..
> > 31: ((FLET #:FORM-FUN-3368 :IN SWANK::HANDLE-REQUESTS))
> > 32: (SWANK::HANDLE-REQUESTS #<SWANK::MULTITHREADED-CONNECTION {1002EDAF63}> NIL)
> > 33: (SWANK-REPL::REPL-LOOP #<SWANK::MULTITHREADED-CONNECTION {1002EDAF63}>)
> > 34: ((LAMBDA NIL :IN SWANK-REPL::SPAWN-REPL-THREAD))
> > 35: (SWANK::CALL-WITH-BINDINGS NIL #<CLOSURE (LAMBDA NIL :IN \
> > SWANK-REPL::SPAWN-REPL-THREAD) {1007E4000B}>)
> > 36: ((LAMBDA NIL :IN SWANK-REPL::SPAWN-REPL-THREAD))
> > 37: ((FLET #:WITHOUT-INTERRUPTS-BODY-1160 :IN \
> > SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
> > 38: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN \
> > SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
> > 39: ((FLET #:WITHOUT-INTERRUPTS-BODY-359 :IN SB-THREAD::CALL-WITH-MUTEX))
> > 40: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN \
> > SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE) {8241CFB}> #<SB-THREAD:MUTEX \
> > "thread result lock" owner: #<SB-THREAD:THREAD "..
> > 41: (SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE #<SB-THREAD:THREAD \
> > "new-repl-thread" RUNNING {1007C34E53}> NIL #<CLOSURE (LAMBDA NIL :IN \
> > SWANK-REPL::SPAWN-REPL-THREAD) {1007C34DFB}> \
> > (#<SB-THREAD:THREAD..
> > 42: ("foreign function: call_into_lisp")
> > 43: ("foreign function: new_thread_trampoline")
> > 44: ("foreign function: _pthread_body")
> > 45: ("foreign function: _pthread_body")
> > 46: ("foreign function: thread_start")
> >
> > > On Tue, May 30, 2017 at 10:49 AM, Jim Newton <jimka.issy@gmail.com> wrote:
> > > Hi, I'm having a small problem with sb-ext:run-program
> > >
> > > When I execute "vmmap -w 1123" at the shell it prints some 2100+ lines of \
> > > output and exists with status 0.
> > > However, when I attempt to evaluate the following expression at the SBCL repl \
> > > in slime, it never returns.
> > > (let* ((pid (format nil "~D" (sb-posix::getpid)))
> > > (string (with-output-to-string (str)
> > > (sb-ext:run-program "vmmap" (list "-w" pid)
> > > > search t
> > > > wait t
> > > > output str))))
> > > string)
> > >
> > > And when I look at the ps output from the shell, I see that mmap -w 1123 is \
> > > running.
> > >
> > >
> > >
> > > The documentation for sb-ext:run-program indicates that if a stream is passed \
> > > as the argument of :output, then the output of the program will be written \
> > > there.
> > > Can someone give me a hint about what's happening?
> > >
> > > Thanks.
> > > Jim
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Sbcl-devel mailing list
> Sbcl-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sbcl-devel
[Attachment #5 (text/html)]
<html><head><meta http-equiv="content-type" content="text/html; \
charset=utf-8"></head><body dir="auto"><div></div><div><br></div><div><br>On 30 May \
2017, at 12:45, Jim Newton <<a \
href="mailto:jimka.issy@gmail.com">jimka.issy@gmail.com</a>> \
wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Does anyone think my \
expectation is reasonable that with-output-to-string should return the string \
containing the printed output of the program, be it "ls -l" or otherwise? Or am \
I misunderstanding something fundamental \
here?</div></div></blockquote><div><br></div>I think your expectation is correct, I \
just tested your "ls -l" snippets and<div>it works as expected here (Debian \
GNU/Linux)</div><div><br></div><div>Cheers, Ralf Mattes</div><div><br><blockquote \
type="cite"><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May \
30, 2017 at 10:59 AM, Jim Newton <span dir="ltr"><<a \
href="mailto:jimka.issy@gmail.com" \
target="_blank">jimka.issy@gmail.com</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div dir="ltr"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px">when I replace the call \
to vmmap with a call to ls, it get even stranger results. </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> (let ((string \
(with-output-to-string (str) </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
(sb-ext:run-program "ls" (list "-l") </span><span class=""><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><div \
class="m_4390405288537652092gmail-IVILX2C-Db-b" \
style="margin:0px;padding:0px;border:0px;color:rgb(136,136,136);font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
:search \
t <br> \
\
:wait t <br> \
\
:output str)))) <br> \
string) <br><br></div></span><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px">non-empty buffer when \
EOF reached while reading from child: #(80 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
114 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
111 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
99 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
101 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
115 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
115 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
58 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
115 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
98 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
99 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
108 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
32 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
91 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
49 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
49 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
50 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
51 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
93 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
10 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
80 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
97 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
116 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
\
\
104 </span><br \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><span \
style="font-family:Arial,Helvetica,sans-serif;font-size:13px"> \
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></blockquote><blockquote \
type="cite"><div><span>------------------------------------------------------------------------------</span><br><span>Check \
out the vibrant tech community on one of the world's most</span><br><span>engaging \
tech sites, <a href="http://slashdot.org">Slashdot.org</a>! <a \
href="http://sdm.link/slashdot">http://sdm.link/slashdot</a></span></div></blockquote><blockquote \
type="cite"><div><span>_______________________________________________</span><br><span>Sbcl-devel \
mailing list</span><br><span><a \
href="mailto:Sbcl-devel@lists.sourceforge.net">Sbcl-devel@lists.sourceforge.net</a></span><br><span><a \
href="https://lists.sourceforge.net/lists/listinfo/sbcl-devel">https://lists.sourcefor \
ge.net/lists/listinfo/sbcl-devel</a></span><br></div></blockquote></div></body></html>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sbcl-devel mailing list
Sbcl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic