From unknown Sat Aug 09 20:46:58 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#11620 <11620@debbugs.gnu.org> To: bug#11620 <11620@debbugs.gnu.org> Subject: Status: libc I/O buffers not flushed confusion Reply-To: bug#11620 <11620@debbugs.gnu.org> Date: Sun, 10 Aug 2025 03:46:58 +0000 retitle 11620 libc I/O buffers not flushed confusion reassign 11620 coreutils submitter 11620 vikas bansal severity 11620 normal tag 11620 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 03 13:55:05 2012 Received: (at submit) by debbugs.gnu.org; 3 Jun 2012 17:55:06 +0000 Received: from localhost ([127.0.0.1]:55983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SbF0p-0006cE-82 for submit@debbugs.gnu.org; Sun, 03 Jun 2012 13:55:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49287) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sb9it-0006fX-Bj for submit@debbugs.gnu.org; Sun, 03 Jun 2012 08:15:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sb9gz-0007Dp-PY for submit@debbugs.gnu.org; Sun, 03 Jun 2012 08:13:58 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:33422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sb9gz-0007Dk-JO for submit@debbugs.gnu.org; Sun, 03 Jun 2012 08:13:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sb9gx-0007XC-U2 for bug-coreutils@gnu.org; Sun, 03 Jun 2012 08:13:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sb9gv-0007DQ-Uy for bug-coreutils@gnu.org; Sun, 03 Jun 2012 08:13:55 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:43372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sb9gv-0007D7-KY for bug-coreutils@gnu.org; Sun, 03 Jun 2012 08:13:53 -0400 Received: by bkcjm19 with SMTP id jm19so3547692bkc.0 for ; Sun, 03 Jun 2012 05:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=SzhpKHYSL8KEHit7dKJaFB/6yGsWvIx9r2uwj+6glPs=; b=HO6EibXpVwEFf/0xRjp5sK0qDktFT0GRoJmIBb6PcWUAPSn/Qe2XOrD4Vaeq7ktgJO hddmX+mYQbS/YfQh06nXazKXtmO9aRs4Ee5e/+ZFZCTOsks8M9SfOCncLMYCkJ+aK2+5 9SEQoObyoKa9nuWnD/UA1S5X+20pNpaNt99UaTYQpYhNlz6ebub3hh0sr4VDJm8oZHKO bSTx2IAvhoXaOQcrhLGbdNoQ0lyo3q7Q54HRba3bKIdw4g0Y2tPZyzDjyt5EvLFOFK+t 91yqIGk93zEoMr21J4mqu7OVXOC+bcfSX5m/L2QcF5Y1CoEpYDsPL7281BXne0XgS69b BczA== MIME-Version: 1.0 Received: by 10.204.129.17 with SMTP id m17mr4731412bks.4.1338725630463; Sun, 03 Jun 2012 05:13:50 -0700 (PDT) Received: by 10.204.132.71 with HTTP; Sun, 3 Jun 2012 05:13:50 -0700 (PDT) Date: Sun, 3 Jun 2012 17:43:50 +0530 Message-ID: Subject: Bug in sleep--linux 2.6 From: vikas bansal To: bug-coreutils@gnu.org Content-Type: multipart/mixed; boundary=0015173fee46a7cfec04c1905954 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 03 Jun 2012 13:54:45 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) --0015173fee46a7cfec04c1905954 Content-Type: multipart/alternative; boundary=0015173fee46a7cfe604c1905952 --0015173fee46a7cfe604c1905952 Content-Type: text/plain; charset=ISO-8859-1 The sleep function when written at the end, forces the program to sleep, preventing him to execute any printf() instructions before it. Attaching a program. -- Vikas Bansal Student(ECE undergraduate final year) The L.N.Mittal Institute of Information Technology,Rajasthan,India. --0015173fee46a7cfe604c1905952 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
The sleep function when written at the end, forces t= he program to sleep, preventing him to execute any printf() instructions be= fore it.
Attaching a program.
--
Vikas Bansal
Studen= t(ECE undergraduate final year)
The L.N.Mittal Institute of Information Technology,Rajasthan,India.
--0015173fee46a7cfe604c1905952-- --0015173fee46a7cfec04c1905954 Content-Type: text/x-csrc; charset=US-ASCII; name="process1.c" Content-Disposition: attachment; filename="process1.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h302nggt0 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9p cGMuaD4KI2luY2x1ZGUgPHN5cy9zaG0uaD4KCiNkZWZpbmUgU0hNU0laRSAyNwoKbWFpbigpCnsK cHJpbnRmKCJnb2luZ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ICgqc2htICE9ICcqJykKc2xlZXAoMSk7CmV4aXQoMCk7Cgp9Cg== --0015173fee46a7cfec04c1905954-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 03 16:37:18 2012 Received: (at 11620-done) by debbugs.gnu.org; 3 Jun 2012 20:37:18 +0000 Received: from localhost ([127.0.0.1]:56038 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SbHY6-0001oH-2Y for submit@debbugs.gnu.org; Sun, 03 Jun 2012 16:37:18 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]:31799) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SbHY3-0001o2-O5 for 11620-done@debbugs.gnu.org; Sun, 03 Jun 2012 16:37:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aq8BAHTJy09tTk4N/2dsb2JhbAANN7BRhnABAQEEMgFGEAsNCwkWDwkDAgECAUUGDQEHAQG9UYsRhhADmw2MZQ Received: from unknown (HELO [192.168.1.79]) ([109.78.78.13]) by mail3.vodafone.ie with ESMTP; 03 Jun 2012 21:35:16 +0100 Message-ID: <4FCBCA84.3070402@draigBrady.com> Date: Sun, 03 Jun 2012 21:35:16 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: vikas bansal Subject: Re: bug#11620: Bug in sleep--linux 2.6 References: In-Reply-To: X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11620-done Cc: 11620-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) tag 11620 notabug On 06/03/2012 01:13 PM, vikas bansal wrote: > The sleep function when written at the end, forces the program to sleep, > preventing him to execute any printf() instructions before it. > Attaching a program. You got the wrong list because you followed `man 1 sleep` rather than `man 3 sleep`. I've not looked at the program at all, but you may need to add some fflush(stdout) calls, to ensure timely output. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 03 16:39:57 2012 Received: (at 11620) by debbugs.gnu.org; 3 Jun 2012 20:39:57 +0000 Received: from localhost ([127.0.0.1]:56046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SbHae-0001u3-Vx for submit@debbugs.gnu.org; Sun, 03 Jun 2012 16:39:57 -0400 Received: from joseki.proulx.com ([216.17.153.58]:60950) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SbHaJ-0001tY-C8; Sun, 03 Jun 2012 16:39:54 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 7BF75211F0; Sun, 3 Jun 2012 14:37:41 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 381C72DC6D; Sun, 3 Jun 2012 14:37:41 -0600 (MDT) Date: Sun, 3 Jun 2012 14:37:41 -0600 From: Bob Proulx To: vikas bansal Subject: Re: bug#11620: Bug in sleep--linux 2.6 Message-ID: <20120603203741.GA8254@hysteria.proulx.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 11620 Cc: 11620@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) retitle 11620 libc I/O buffers not flushed confusion tag 11620 + notabug close 11620 thanks vikas bansal wrote: > The sleep function when written at the end, forces the program to sleep, > preventing him to execute any printf() instructions before it. You have confused the sleep(3) libc C library routine with the coreutils sleep(1) command line utility. Please see this reference: http://www.gnu.org/software/coreutils/faq/#I-am-trying-to-compile-a-C-program-_002e_002e_002e > Attaching a program. Thank you for showing us the program even if it isn't anything to do with coreutils. > printf("going to sleep"); Missing "\n" newline at end of line? > while (*shm != '*') > sleep(1); > exit(0); The misunderstanding you are seeing is that printf() is calling the libc stdio function which is buffering the output data. This data is only flushed when exit() is called. The libc buffers data differently depending upon the context of the file such as if the output is a tty or a file. If you wish to ensure that data is output then you should fflush() the data in the libc I/O buffers. http://pubs.opengroup.org/onlinepubs/009696799/functions/fflush.html Bob From unknown Sat Aug 09 20:46:58 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 02 Jul 2012 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator