don-sourceforge-xxzw@... (Don Cohen) writes:
> Now, if you write scripts that launch clisp, as their final step, you
> can use exec to make them chain clisp without calling fork:
> I'm trying to figure out what this fork has to do with it.
>
> #!/bin/bash
> echo "I'm a script launching clisp"
> exec /usr/bin/clisp -q -ansi
>
> I gather you're saying that if my batch file had the exec my ps
> tree would be
>
> pid ppid command
> 1036 1 /usr/sbin/sshd -D
> 7005 1036 \_ sshd: jack [priv]
> 7010 7005 \_ sshd: jack@...
> 7011 7010 \_ -bash
> 29274 7011 \_ /usr/lib/clisp-2.49/base/lisp.run ...
> instead of
>
> 29274 7011 \_ /bin/bash ./adm2012
> 29275 29274 \_ /usr/lib/clisp-2.49/base/lisp.run ...
>
> In that case, why would I not end up with
> 29274 1 /usr/lib/clisp-2.49/base/lisp.run ...
> after the ssh ends instead of
> 29275 1 /usr/lib/clisp-2.49/base/lisp.run ...
> What is it that causes process 7011 to end when 7010 ends
> and that causes 29274 to end when 7011 ends but does not
> cause 29275 to end when 29274 ends ?
Depends on how you run ssh, but in the normal cases, ssh will fork a
bash.
ssh user@...
forks the shell indicated in /etc/passwd for user.
ssh user@... /usr/bin/clisp
doesn't fork a bash.
ssh user@... bash -c 'exec /usr/bin/clisp'
forks a bash, and then exec clisp. This variant can be useful if you
want to do something in bash before exec'ing clisp, such as expanding
file patterns or setting redirections.
> As it happens, I prefer to see the script in the ps list, since it
> gives me useful information about what that lisp process is doing.
> I even have programs that look for such information.
> /usr/bin/clisp or clisp.exe are binary executables.
> Isn't /bin/bash also?
Yes, but not the scripts.
You can also write clisp scripts:
#!/usr/bin/clisp -q -ansi
…
and then run them directly. That may give you the "useful information"
while avoiding forking another process.
> There are also cases where I wish I knew how to NOT kill a process
> when its parent ends.
You really need to learn more about unix! Use the manual!
man bash
> For instance, when I kill a server process
> and then restart it, I'd really like it to continue to serve if/when
> the shell from which I restarted it ends.
server & disown
exit
This is explained in man bash. Why don't you read the manual?
> So what I'm really asking is how to control the effect on the child
> of the termination of its parent.
>
> I realize this is getting pretty far from the topic of clisp.
> I'd be happy to accept a link to more detailed information.
> BTW, does all of this work the same in Windows as in unix, or even
> the same in all variants of unix ?
Basically it's the same in all POSIX systems. MS-Windows has extensions
making it more posix-like. I use cygwin on MS-Windows.
User interface questions such as how to fork a server process and detach
it from the controlling terminal are answed in the manual of the shell
providing the user interface! I proposed man bash, but you can type
man sh ; man tcsh ; man whatever!
Try:
apropos shell
too.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
|