This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Run program in background.
- From: "Reid Thompson" <Reid dot Thompson at ateb dot com>
- To: <cygwin at cygwin dot com>
- Date: Tue, 5 Oct 2004 09:44:11 -0400
- Subject: RE: Run program in background.
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/