R
rantingnews
Deal all,
It is a trivial question, i know. I have few lines of POSIX code that
I don't know if I can express them with simple ANSI C. These are
simple:
read(0, buffer, len);
write(1, buffer, len);
I have tried to simply translate them to
fread(buffer, 1, len, stdin);
fwrite(buffer, 1, len, stdout);
but the program (started by a server) doesn't work. It seems that my
program (started by a server, not by me directly) when using read/
write works, while with fread/fwrite expects something from stdin/
stdout (I suppose, and it is actually what those calls would do). In
practice, it would seem that on read(0, ...) stdin is redirected
somehow, although I don't know anything about it.
Am I misinterpreting read/write ?
Thanks!
It is a trivial question, i know. I have few lines of POSIX code that
I don't know if I can express them with simple ANSI C. These are
simple:
read(0, buffer, len);
write(1, buffer, len);
I have tried to simply translate them to
fread(buffer, 1, len, stdin);
fwrite(buffer, 1, len, stdout);
but the program (started by a server) doesn't work. It seems that my
program (started by a server, not by me directly) when using read/
write works, while with fread/fwrite expects something from stdin/
stdout (I suppose, and it is actually what those calls would do). In
practice, it would seem that on read(0, ...) stdin is redirected
somehow, although I don't know anything about it.
Am I misinterpreting read/write ?
Thanks!