>>4 Is there any way to make pipes flush automatically?
Give them a handjob.
Name:
Anonymous2011-10-25 11:12
I mean disabling a child process's stdout buffring from parent process. setvbuf(stdout,NULL,_IOLBF,0);
works but If only it is executed from child program, which will be third party
Name:
Anonymous2011-10-25 11:16
>>1
scanf("%s", t); i see a buffer overflow waiting to happen.
>>9
This program will be used for evaluating students' assignments. I hope that they output something wrong and my program crashes, it will be their problem.
Name:
Anonymous2011-10-25 11:38
1)you should pipe things before forking
2)you dont pass any args to execl so expect a shitrstorm when
opening an fd
3)how did you manage to create such a mess in 30 lines?
4)you should really do your homework first
Name:
Anonymous2011-10-25 12:08
>>11 you should pipe things before forking
huh? pipe things between what? you dont pass any args to execl so expect a shitrstorm when opening an fd
I pass the name of the program ("c") as first argument and nothing else. what is wrong with it? how did you manage to create such a mess in 30 lines?
as I said, it is for learning purposes. I am not that familiar with pipes and fork. and I don't find my code that messed up. maybe it is you you should really do your homework first
I am an assistant, not a student. I don't do homeworks, bitch.
>>17
well, if that is all good bye. and please use sage next time when you have nothing to contribute and planning to be a bitch. especially when you are wrong. >>16
thanks, I will try it tomorrow.
Name:
Anonymous2011-10-25 12:46
>>18
fuck i am off the stupidity in this place is astonishing
Name:
Anonymous2011-10-26 6:35
>>6 I mean disabling a child process's stdout buffring from parent process.
Damn, boy. This buffering is performed by the child. When you call `printf` there it puts results into a piece of malloc'd memory. OS is not involved, so you can't tell it to disable buffering from another process.
Name:
Anonymous2011-10-26 8:14
How much is it buffered? Are you not getting anything until the child exits?
A possible solution, which sounds ghastly is to have the parent look like a tty from the chld's point of view. I think this would make it line-buffered (ie auto flush after \n).
>>16
nah, this enables or disables blocking. or am I mistaken? >>20
:( well it is not that important. I will ask students to set their stdout buffers to null. >>21
it just waits. Childs will be sending simple integers to server so it will be only a few bytes. It is buffered forever.
Weird thing \n does not the flush the buffer. It does while printing to console but not when it is a pipe.
Anyway it does not matter much. Asking students to insert setvbuf(stdout, NULL, _IOLBF, 0); to their code is not that much. Or maybe I can fix source files by hand
Damn, boy. This buffering is performed by the child. When you call `printf` there it puts results into a piece of malloc'd memory. OS is not involved, so you can't tell it to disable buffering from another process.
Holy shit are you a dumbass. First off, a call to printf() doesn't necessarily mean the results are put into a piece of malloc'd memory. The second thing, the OS is involved. Now perhaps instead of jerking off to SICP, perhaps you should actually purchase and read "Advanced Programming in the Unix Environment" by Stevens and Rago.
>>22
Yes that's expected.. If it's a terminal it's line buffered. With the pipe it's buffered into larger chunks (maybe 1024 or something), because its not a tty.
If you appear as a tty to the child then it will line buffer there too. Hence openpty etc.
Yes that's expected.. If it's a terminal it's line buffered
Again, you are a stupid fucker. And I quote pages 135 and 136 in "Advanced Programming in the Unix Environment" by Stevens and Rago.
"Line buffering is typically used on a stream when it refers to a terminal: standard input and standard output for example.
Line buffering comes with two caveats. First, the size of the buffer that the standard I/O library is using to collect each line is fixed, so I/O might take place if we fill the buffer before a newline. Second, whenever input is requested through the standard I/O library from either (a) an unbuffered stream or (b) a line-buffered stream."
Do you see anything that requires a terminal, when used as a predicate, to be true? Because I sure a hell don't.
It is mentioned in the word might. The common implementation of the standard IO library is to use line buffering when writing to a terminal, and wait-till-le-buffar-es-full buffering when writing to something that is not a terminal. If you would like to get a program that uses line buffering only when writing to a terminal, because it relies on a library with such behavior for its IO, then the only way to get it to do line buffering when not writing to a terminal is to fake it out into thinking it is writing to a terminal via a virtual terminal, although if it is open source you could modify what it uses for io, but this isn't practical in general.
Name:
Anonymous2011-10-26 23:02
>>32 Nobody knows how much space should be reserved for name.
It's obviously a pathname so it should be PATH_MAX+1.