On 11 Aug 1999, Adam Morrison wrote:
No, you're right.
I was referring to something else completely, and thus this
misunderstanding.
To better explain.
If you try backgrounding a process why it waits for input:
host:~> ftp host
ftp> ^Z
Suspended
host:~> bg
[1] ftp ftp &
host:~> <newline>
[1] + Suspended (tty input) ftp ftp
host:~> exit
There are suspended jobs.
host:~> kill -9 $$
ssh host ...
host:~> ps ax|grep ftp|grep -v grep
host:~>
Naturally, if you first do:
ftp> get somefile
^Z
host:~> bg
host:~> exit
it will work, since it's not suspended at tty input.
anyway, I apologize for this long thread, I was going to a rather
different direction than what was asked here...
and you are right of course Adam.
--Ariel
> In <[EMAIL PROTECTED]>, Ariel Biener
><[EMAIL PROTECTED]> writes:
>
> > Second, ftp WILL exit when it loses the control terminal. Try it, from
> > bash or tcsh.
>
> I explained this behavior previously.
>
> When the terminal goes away, the program will start getting
> errors on write()s to the terminal.Whether it exits or not
> at that point depends on how well it is written.
>
> Simply, if ftp attempts to receive input from the user and fails, it
> exits.This is correct behavior, why should it stick around?
>
> Therefore, when using a shell with job control, it's quite
> straightforward to do the following:
>
> ftp> get big-file
> 150 Opening BINARY mode data connection for big-file (lots of bytes).
> ^Z
> Suspended
> % bg
> [1] ftp
> % exit
>
> When ftp finishes the transfer, it'll exit by itself because of the
> above mentioned condition.(It doesn't try reading from the terminal
> while transferring the file.)Come to think of it, I've been doing
> this forever!
>
> Because ftp is run in a background process group, the kernel doesn't
> send it a SIGHUP when the shell exits.Had you run something similar
> from a shell without job control (which isn't as simple as the example
> above, since you can't suspend and `bg' jobs in a shell WITHOUT job
> control!), then ftp would die immediately when the shell exited.
>
> > In fact, most Unix utilities will exit when losing the control terminal.
>
> If the application expects to get input, and it can't do so (because
> it lost its terminal), I'd expect it to exit.Like I said, that's
> correct behavior.
>
> To decide based on observing this behavior that job control doesn't
> work, which is basically what you were saying... that's quite a
> stretch.
>
> > You are welcome to prove me otherwise, and this way I might learn
> > something.
>
> I explained what's going on, twice.
>
> Which part were you disputing, exactly?
>
> The fact that background jobs started from a shell with job control
> don't die when the shell exits?
>
> bash$ sleep 666 &
> [1] 31187
> bash$ exit
> Connection to linux-box closed.
> % ssh linux-box
> Last login: Wed Aug 11 19:00:46 1999 from vortex
> You have new mail.
> bash$ ps -p 31187
> PID TTY TIME CMD
> 31187 ? 00:00:00 sleep
>
>
> Or my explanation of how job control works?
>
> $ cat wrapper.c
> #include <sys/types.h>
> #include <unistd.h>
> #include <stdio.h>
>
> int
> main(int argc, char **argv)
> {
> if (argc < 3) {
> fprintf(stderr, "usage: wrapper path args\n");
> return (1);
> }
> if (setpgid(0, getpid()) == -1) {
> perror("setpgid");
> return (1);
> }
> if (execv(argv[1], &argv[2]) == -1) {
> perror("exec");
> return (1);
> }
> /*NOTREACHED*/
> }
> $ gcc -o setpgid wrapper.c
> $ ./setpgid /usr/bin/sleep sleep 666 &
> 9616
> $ exit
> Connection to solaris-box closed.
> % ssh solaris-box
> Last login: Wed Aug 11 11:23:52 1999from vortex
> Sun Microsystems Inc. SunOS 5.6 Generic August 1997
> You have mail.
> $ ps -p 9616
> PID TTY TIME CMD
> 9616 ? 0:00 sleep
> $ sleep 666 &
> 9624
> $ exit
> Connection to solaris-box closed.
> % ssh solaris-box
> Last login: Wed Aug 11 11:33:52 from vortex
> Sun Microsystems Inc. SunOS 5.6 Generic August 1997
> You have mail.
> $ ps -p 9624
> PID TTY TIME CMD
> $ exit
>
>
> =================================================================
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
>
--
Ariel Biener
e-mail: [EMAIL PROTECTED] Work phone: 03-640608
fingerprint = 07 D1 E5 3E EF 6D E5 82 0B E9 21 D4 3C 7D 8B BC
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]