How do I reacquire the terminal in the following in case - Unix

This is a discussion on How do I reacquire the terminal in the following in case - Unix ; I have a program like the following m-net% more ses.c #include #include #include int main(void) { pid_t pid; if((pid = fork()) fprintf(stderr, "can't fork\n"); exit(1); } if(pid != 0) exit(1); sleep(5000); return 0; } m-net% gcc -g ses.c -o ses ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: How do I reacquire the terminal in the following in case

  1. How do I reacquire the terminal in the following in case

    I have a program like the following

    m-net% more ses.c
    #include
    #include
    #include

    int main(void)
    {
    pid_t pid;

    if((pid = fork()) < 0) {
    fprintf(stderr, "can't fork\n");
    exit(1);
    }

    if(pid != 0)
    exit(1);

    sleep(5000);
    return 0;
    }

    m-net% gcc -g ses.c -o ses
    m-net% ./ses
    m-net% ps waux | grep cdalten
    cdalten 77563 0.0 0.2 3748 2404 p8 SN 11:01PM 0:00.21 -zsh
    (zsh)
    cdalten 77743 0.0 0.0 1256 484 p8 SN 11:11PM 0:00.00 ./ses
    cdalten 77744 0.0 0.1 1564 964 p8 RN+ 11:11PM 0:00.00 ps
    waux
    cdalten 77745 0.0 0.2 3748 2404 p8 RN 11:11PM 0:00.00 -zsh
    (zsh)
    m-net%

    Now I logout and log back in again

    m-net% ps waux | grep cdalten
    cdalten 77770 0.2 0.2 3716 2312 p4 RN 11:12PM 0:00.14 -zsh
    (zsh)
    cdalten 77786 0.0 0.1 1564 964 p4 RN+ 11:12PM 0:00.00 ps
    waux
    cdalten 77743 0.0 0.0 1256 480 p8- IN 11:11PM 0:00.00 ./ses
    m-net%


    The program is still running on ttyp8. Is there anyway I can get this
    to run on tty4 (the terminal that I'm currently on)?



  2. Re: How do I reacquire the terminal in the following in case

    In article
    <16d34165-194e-44ed-8b66-b3613f9b1f2a@26g2000hsk.googlegroups.com>,
    K-mart Cashier wrote:

    > I have a program like the following
    >
    > m-net% more ses.c
    > #include
    > #include
    > #include
    >
    > int main(void)
    > {
    > pid_t pid;
    >
    > if((pid = fork()) < 0) {
    > fprintf(stderr, "can't fork\n");
    > exit(1);
    > }
    >
    > if(pid != 0)
    > exit(1);
    >
    > sleep(5000);
    > return 0;
    > }
    >
    > m-net% gcc -g ses.c -o ses
    > m-net% ./ses
    > m-net% ps waux | grep cdalten
    > cdalten 77563 0.0 0.2 3748 2404 p8 SN 11:01PM 0:00.21 -zsh
    > (zsh)
    > cdalten 77743 0.0 0.0 1256 484 p8 SN 11:11PM 0:00.00 ./ses
    > cdalten 77744 0.0 0.1 1564 964 p8 RN+ 11:11PM 0:00.00 ps
    > waux
    > cdalten 77745 0.0 0.2 3748 2404 p8 RN 11:11PM 0:00.00 -zsh
    > (zsh)
    > m-net%
    >
    > Now I logout and log back in again
    >
    > m-net% ps waux | grep cdalten
    > cdalten 77770 0.2 0.2 3716 2312 p4 RN 11:12PM 0:00.14 -zsh
    > (zsh)
    > cdalten 77786 0.0 0.1 1564 964 p4 RN+ 11:12PM 0:00.00 ps
    > waux
    > cdalten 77743 0.0 0.0 1256 480 p8- IN 11:11PM 0:00.00 ./ses
    > m-net%
    >
    >
    > The program is still running on ttyp8. Is there anyway I can get this
    > to run on tty4 (the terminal that I'm currently on)?


    No.

    But if what you really want to do is start a program, keep it running
    while you logout, and then connect back to it later when you login, you
    should use "screen".

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  3. Re: How do I reacquire the terminal in the following in case

    On 9 Aug, 06:02, Barry Margolin wrote:
    > In article
    > <16d34165-194e-44ed-8b66-b3613f9b1...@26g2000hsk.googlegroups.com>,
    > *K-mart Cashier wrote:


    > > * if((pid = fork()) < 0) {
    > > * * fprintf(stderr, "can't fork\n");
    > > * * exit(1);
    > > * }



    man perror


+ Reply to Thread