C
chad kline
FBSD 4.8/GCC
////////
C-CODE:
////////
char c;
while ( 1 ) {
read(0, &c, 1); printf("%02x ", c);
close(0); open("/dev/stdin", O_RDWR, S_IRUSR|S_IWUSR);
}
//////////
Question:
//////////
this is confusing to me. 'open' doesn't reopen 'stdin'
('errno' keeps getting set, and no new characters are
ever read - after the 1st one).
i have a function that opens, reads, and closes a file.
i would like to use this function to read a file piped
from 'stdin' as well as from disk. the problem is i
can't re-open 'stdin' after the file reading function
closes '/dev/stdin'.
is there any way to "reset" /dev/stdin so that
it functions normally after being close(2)'d?
////////
C-CODE:
////////
char c;
while ( 1 ) {
read(0, &c, 1); printf("%02x ", c);
close(0); open("/dev/stdin", O_RDWR, S_IRUSR|S_IWUSR);
}
//////////
Question:
//////////
this is confusing to me. 'open' doesn't reopen 'stdin'
('errno' keeps getting set, and no new characters are
ever read - after the 1st one).
i have a function that opens, reads, and closes a file.
i would like to use this function to read a file piped
from 'stdin' as well as from disk. the problem is i
can't re-open 'stdin' after the file reading function
closes '/dev/stdin'.
is there any way to "reset" /dev/stdin so that
it functions normally after being close(2)'d?