<m_mans>
it seems that *older* interfaces return only first byte, but in modern systems exit status is 32bit. Got it now
<Regenaxer>
ah, 32, ok
<Regenaxer>
yes
<Regenaxer>
ld4 (S) # Result?
<Regenaxer>
line 3352 in src64/flow.l
<Regenaxer>
ld4 gets 4 bytes, 32 bits
alexshendi has joined #picolisp
<aw->
Regenaxer: i got it!
<Regenaxer>
Works without '+'?
<aw->
no
<aw->
you were right all along
<Regenaxer>
:(
<aw->
cooked/raw
<aw->
i did (raw NIL)
<aw->
and then use (exec 'extprogram)
<Regenaxer>
ah! :)
<aw->
works fine
<Regenaxer>
good
<aw->
all my tests were with (call 'extprogram)
<m_mans>
I didn't know before that curl can easily send emails :)
<Regenaxer>
cool, didn't know either
<aw->
probably better to do (unless (fork) (exec ...)
<aw->
so my code keeps running ;)
<Regenaxer>
true
<aw->
hmmm... no.. i need it to wait for the (exec) to end
<Regenaxer>
then call is fine
rob_w has joined #picolisp
<aw->
no
<aw->
doesn't work with (call)
<aw->
i'm not sure what's different between (call) and (exec).. but (exec) seems to work fine with the extprogram... (call) doesn't
<Regenaxer>
'call' does cc setpgid(0 0) # Set process group
<Regenaxer>
this must be the reason
<Regenaxer>
It is needed so that ^Z (SIGSTP) is passed through iirc
<aw->
hmmm
<Regenaxer>
a mess ;)
<Regenaxer>
Without it, (call 'vi) does not behave well in such cases (iirc)
<aw->
haha
<aw->
ok question
<aw->
how do I (exec) and wait for it to complete?
<aw->
(unless (fork) (exec ..) (wait) ?
<Regenaxer>
no
<Regenaxer>
that's another wait
<Regenaxer>
exec does not even return
<Regenaxer>
Only 'call' and 'in/out' wait for the child
<Regenaxer>
You could use 'in'
<Regenaxer>
(in '("extprog" ..)
<Regenaxer>
but then your main process waits just as in 'call'
<aw->
yes i want the main process to wait
<Regenaxer>
ok, then 'in' or 'out'
<Regenaxer>
better 'in' I would say
<Regenaxer>
without any reading from the process's stdout
<aw->
(in does the same thing as (call
<aw->
doesn't work
miskatonic has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
orivej has quit [Ping timeout: 256 seconds]
<aw->
Regenaxer: what does this mean: "the current process is replaced with a new process image. " ?
<aw->
what is a process image?
orivej has joined #picolisp
<beneroth>
aw-, the executable which is running
<beneroth>
I would think
<beneroth>
"the current process is replaced with a new process image. " -> the newly started process takes over the Pid from the current process. the current process ceases to exist kinda.
<beneroth>
this is my understanding. not sure it this helps you :)
<aw->
hmmm
<aw->
why does it do that?
<beneroth>
probably it is inspired by the linux exec. man exec.
<beneroth>
"original process identifier (PID) does not change, but the machine code, data, heap, and stack of the process are replaced by those of the new program."
<aw->
beneroth: thanks
<beneroth>
apparently everything gets replaced by the new program, except for file descriptors. so the new program can inherit stdin/stdout/stderr. and probably other open file descriptors?
<beneroth>
dunno if this is the same for the picolisp exec
<Regenaxer>
yes, correct
<Regenaxer>
it calls directly the exexXXX() system call
<aw->
hmmm... ok so in that case i will do (exec 'somebashscript), and that script will simply call 'extprogram, and then continue processing as i wish
<aw->
it's the only way
<beneroth>
aw-, apparently, in the past exec was used to save memory (as the memory of the calling process gets freed just before / right when the new process starts)
<Regenaxer>
call is fork + exec basically
<beneroth>
Regenaxer, so all open file descriptors get inherited by new process? (including e.g. an opened pilDB) ?
<Regenaxer>
yes, but pil sets closeonexec on such FDs
<Regenaxer>
io.l:(code 'closeOnExecAX)
orivej has quit [Ping timeout: 256 seconds]
<beneroth>
oh ok
<Regenaxer>
What is usually interesting is stdio
<beneroth>
maybe also useful to share a common log file between serially running processes
<Regenaxer>
This is the really brilliant feature of Unix
<Regenaxer>
fork and exec are separate
<Regenaxer>
Windows has just spawn()
<Regenaxer>
for a new process
<Regenaxer>
yes, log files too, but I use stdout and stderr for that
<beneroth>
btw I heard in unix it is possible to hand over a file descriptor (e.g. a socket) to another process. would this also possible with pil, e.g. handing a socket via (tell)-pipe to a child ?
<Regenaxer>
Not sure, haven't looked at that
<beneroth>
this would be interesting for a non-forking server architecture
<beneroth>
ok
<Regenaxer>
yes
<Regenaxer>
Probably with 'native'
<aw->
thanks for the help Regenaxer and others
<Regenaxer>
:)
<aw->
you're all awesome
<aw->
and Linux tty stuff is a mess
<Regenaxer>
sadly yes
<Regenaxer>
Not Linux' fault though
<Regenaxer>
bbl
<Regenaxer>
ret
alexshendi has quit [Ping timeout: 256 seconds]
orivej has joined #picolisp
orivej has quit [Client Quit]
orivej has joined #picolisp
<cess11>
I've generated bash scripts and run them from pil sometimes
<cess11>
not often but it happens that this is the easiest way