delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/05/09:44:29

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
content-class: urn:content-classes:message
MIME-Version: 1.0
Subject: RE: Run program in background.
Date: Tue, 5 Oct 2004 09:44:11 -0400
Message-ID: <64AE3D5B518E3648ACC823FBCB0B737502A6B3FB@sr002-2kexc.ateb.com>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
From: "Reid Thompson" <Reid DOT Thompson AT ateb DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id i95DiRaD023204

Brian Dessent wrote:
> 
> If you just want your program to simply run in the
> background, launch it with a "&" at the end of the command
> from the shell.  However, if it expects to use stdout, stdin,
> or stderr, it will stop -- so these must all be redirected to files
> or pipes. 

not exactly correct the program does not stop, stdin is not accessible
via the shell, but stdout and stderr are by default, still routed to it.

$ cat back.c
#include <stdio.h>

int main (void)
{
    int ctr = 0;

    printf("From stdout\n");
    fprintf(stderr, "From stderr\n");

    for (ctr = 0; ctr < 5; ++ctr)
    {
        printf("%d\n", ctr);
        sleep(2);
    }

    return(0);
}
WS-XP-4960:/home/rthompso> 
$ ./a &
[2] 5076
WS-XP-4960:/home/rthompso> 
$ From stdout
From stderr
0
1
2
3
4
[2]+  Done                    ./a

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019