From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20118 invoked by alias); 9 Oct 2008 18:34:16 -0000 Received: (qmail 19623 invoked by uid 48); 9 Oct 2008 18:32:54 -0000 Date: Thu, 09 Oct 2008 18:34:00 -0000 Subject: [Bug c/37785] New: printf + sleep = problems with output buffer X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "alexcastan at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg00642.txt.bz2 PLATFORM PC i386 + GNU/Linux Ubuntu Hardy 8.04 + GCC 4.2.3 Compiling and Linking options: none. Excuse my poor English. (By the way, what is "Host triplet", "Target triplet", "Build triplet"?) BUG: "printf" really prints at terminal when finds '\n' character. So if I have a simple "printf" iteration without '\n' like this ... int n; for (n=10; n>=0; n--) { printf("%d ", n); sleep(1); }; ... it doesn't works like expected. It just waits 10 seconds without printing anything. After that prints whole line. Another related problem with printf without '\n' and printf buffer using fork, but I don't know if it is problem with printf or fork: int n, pid; for (n=10; n>=0; n--) { printf("%d ", n); sleep(1); }; pid = fork(); if (pid == -1) printf("Error\n"); else if (pid == 0) printf("I'm the child\n"); else printf("I'm the parent\n"); it prints TWO times 10 9 8 7 6 5 4 3 2 1 0 It is not that executes two times, but if the fork send again the buffer to the screen. -- Summary: printf + sleep = problems with output buffer Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alexcastan at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37785