Click here to Skip to main content
15,914,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Question about stdin under multi-process environment. Pin
Johnny ²26-Jul-03 4:28
Johnny ²26-Jul-03 4:28 
GeneralRe: Question about stdin under multi-process environment. Pin
George226-Jul-03 16:48
George226-Jul-03 16:48 
GeneralRe: Question about stdin under multi-process environment. Pin
Johnny ²26-Jul-03 21:30
Johnny ²26-Jul-03 21:30 
GeneralRe: Question about stdin under multi-process environment. Pin
George227-Jul-03 1:14
George227-Jul-03 1:14 
GeneralRe: Question about stdin under multi-process environment. Pin
Johnny ²27-Jul-03 6:52
Johnny ²27-Jul-03 6:52 
GeneralRe: Question about stdin under multi-process environment. Pin
George227-Jul-03 15:40
George227-Jul-03 15:40 
GeneralRe: Question about stdin under multi-process environment. Pin
Bob Stanneveld25-Jul-03 23:55
Bob Stanneveld25-Jul-03 23:55 
GeneralRe: Question about stdin under multi-process environment. Pin
George226-Jul-03 1:03
George226-Jul-03 1:03 
Thanks, Bob buddy!

But I am but agree with you. Under Linux environment, even if a parent process close stdin and the child process can still read from stdin.

I can give you an example, the codes are taken from open source project,
miniterm,

--------
switch (fork())
{
case 0: /* child */
/* user input */
close(1); /* stdout not needed */
for (c=getchar(); c!= ENDMINITERM ; c=getchar()) write(fd,&c,1);
tcsetattr(fd,TCSANOW,&oldtio); /* restore old modem setings */
tcsetattr(0,TCSANOW,&oldstdtio); /* restore old tty setings */
close(fd);
exit(0); /* will send a SIGCHLD to the parent */
break;
case -1:
perror("fork");
tcsetattr(fd,TCSANOW,&oldtio);
close(fd);
exit(-1);
default: /* parent */
close(0); /* stdin not needed */
sa.sa_handler = child_handler;
sa.sa_flags = 0;
sigaction(SIGCHLD,&sa,NULL); /* handle dying child */
while (STOP==FALSE) /* modem input handler */
{
read(fd,&c,1); /* modem */
write(1,&c,1); /* stdout */
}
wait(NULL); /* wait for child to die or it will become a zombie */
break;
}
--------

So, what do you think about it?


regards,
George
GeneralRe: Question about stdin under multi-process environment. Pin
Bob Stanneveld27-Jul-03 1:09
Bob Stanneveld27-Jul-03 1:09 
GeneralRe: Question about stdin under multi-process environment. Pin
George227-Jul-03 1:15
George227-Jul-03 1:15 
GeneralLinking error Pin
eddymohd25-Jul-03 17:58
eddymohd25-Jul-03 17:58 
GeneralRe: Linking error Pin
Michael Dunn25-Jul-03 18:20
sitebuilderMichael Dunn25-Jul-03 18:20 
GeneralRe: Linking error Pin
eddymohd25-Jul-03 19:08
eddymohd25-Jul-03 19:08 
GeneralRe: Linking error Pin
Bob Stanneveld25-Jul-03 19:32
Bob Stanneveld25-Jul-03 19:32 
GeneralRe: Linking error Pin
Michael Dunn25-Jul-03 20:21
sitebuilderMichael Dunn25-Jul-03 20:21 
GeneralRe: Linking error Pin
Bob Stanneveld25-Jul-03 23:45
Bob Stanneveld25-Jul-03 23:45 
GeneralRe: Linking error Pin
Atlantys26-Jul-03 10:32
Atlantys26-Jul-03 10:32 
GeneralGetting Selection from CHTMLEditView Pin
Matt Gates25-Jul-03 15:53
Matt Gates25-Jul-03 15:53 
GeneralRe: Getting Selection from CHTMLEditView Pin
Tom Archer25-Jul-03 16:32
Tom Archer25-Jul-03 16:32 
GeneralRe: Getting Selection from CHTMLEditView Pin
Matt Gates25-Jul-03 19:53
Matt Gates25-Jul-03 19:53 
GeneralRe: Getting Selection from CHTMLEditView Pin
Tom Archer26-Jul-03 2:33
Tom Archer26-Jul-03 2:33 
GeneralRe: Getting Selection from CHTMLEditView Pin
Tom Archer26-Jul-03 2:35
Tom Archer26-Jul-03 2:35 
GeneralRe: Getting Selection from CHTMLEditView Pin
Matt Gates26-Jul-03 15:58
Matt Gates26-Jul-03 15:58 
GeneralRe: Getting Selection from CHTMLEditView Pin
Niall Barr26-Jul-03 4:30
professionalNiall Barr26-Jul-03 4:30 
Questionhow to make a groupbox's title transparent Pin
allenhu25-Jul-03 15:28
allenhu25-Jul-03 15:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.