public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46672] New: Problem with fork and buffer
@ 2010-11-26 9:35 debayanin at gmail dot com
2010-11-26 10:44 ` [Bug c/46672] " rguenth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: debayanin at gmail dot com @ 2010-11-26 9:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46672
Summary: Problem with fork and buffer
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: debayanin@gmail.com
I typed the following program on my machine:
#include <stdio.h>
int main()
{
printf("Hello");
fork();
printf("World");
}
The output I get is: HelloWorldHelloWorld
I then change line number 5:
#include <stdio.h>
int main()
{
printf("Hello\n");
fork();
printf("World");
}
The output becomes:
Hello
WorldWorld
So in effect adding a \n eats up a Hello\n as well.
I think this is a bug, but not sure where.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/46672] Problem with fork and buffer
2010-11-26 9:35 [Bug c/46672] New: Problem with fork and buffer debayanin at gmail dot com
@ 2010-11-26 10:44 ` rguenth at gcc dot gnu.org
2010-11-26 11:06 ` debayanin at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-26 10:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46672
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-26 10:28:58 UTC ---
Concurrent writes to stdout (any files) invoke undefined behavior.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/46672] Problem with fork and buffer
2010-11-26 9:35 [Bug c/46672] New: Problem with fork and buffer debayanin at gmail dot com
2010-11-26 10:44 ` [Bug c/46672] " rguenth at gcc dot gnu.org
@ 2010-11-26 11:06 ` debayanin at gmail dot com
2010-11-26 11:11 ` schwab@linux-m68k.org
2010-11-26 11:25 ` manu at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: debayanin at gmail dot com @ 2010-11-26 11:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46672
Debayan Banerjee <debayanin at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
--- Comment #2 from Debayan Banerjee <debayanin at gmail dot com> 2010-11-26 10:44:45 UTC ---
(In reply to comment #1)
> Concurrent writes to stdout (any files) invoke undefined behavior.
I dont think its undefined. For my compiler it always produces this output. I
tried the same on http://ideone.com (dont know which compiler they are using)
and it prints the correct output.
Also, doesnt each process have its own stdout?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/46672] Problem with fork and buffer
2010-11-26 9:35 [Bug c/46672] New: Problem with fork and buffer debayanin at gmail dot com
2010-11-26 10:44 ` [Bug c/46672] " rguenth at gcc dot gnu.org
2010-11-26 11:06 ` debayanin at gmail dot com
@ 2010-11-26 11:11 ` schwab@linux-m68k.org
2010-11-26 11:25 ` manu at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: schwab@linux-m68k.org @ 2010-11-26 11:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46672
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> 2010-11-26 10:51:06 UTC ---
There is nothing lost. If stdout is line buffered then \n forces a flush.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/46672] Problem with fork and buffer
2010-11-26 9:35 [Bug c/46672] New: Problem with fork and buffer debayanin at gmail dot com
` (2 preceding siblings ...)
2010-11-26 11:11 ` schwab@linux-m68k.org
@ 2010-11-26 11:25 ` manu at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2010-11-26 11:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46672
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu.org
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2010-11-26 11:05:56 UTC ---
Undefined: http://c-faq.com/ansi/undef.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-26 11:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-26 9:35 [Bug c/46672] New: Problem with fork and buffer debayanin at gmail dot com
2010-11-26 10:44 ` [Bug c/46672] " rguenth at gcc dot gnu.org
2010-11-26 11:06 ` debayanin at gmail dot com
2010-11-26 11:11 ` schwab@linux-m68k.org
2010-11-26 11:25 ` manu at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).