redirect program output into a log file does not seem to work properly when there is sleep in the program

Bug #1195394 reported by Yuan Song
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

Redirect does not seem to work properly when program uses a sleep. I used the following test program. It works well if I do not redirect the output If I redirect the output to a file, I won't see anything in the file. tail -f does not show me anything. I can do redirect if I remove the sleep. I am using 64bits 13.04 with 3.8.0-25-generic #37 kernel. bash version is version 4.2.45(1).

#include <stdio.h>
#include <sys/time.h>
#include <time.h>

int main()
{
 struct timeval tv;
 struct tm* ltm;

 while(1)
{
 sleep(1);
 gettimeofday(&tv, NULL);
 ltm = localtime(&tv.tv_sec);

   printf("%s\n", asctime(ltm));
}
}

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: bash 4.2-5ubuntu3
ProcVersionSignature: Ubuntu 3.8.0-25.37-generic 3.8.13
Uname: Linux 3.8.0-25-generic x86_64
ApportVersion: 2.9.2-0ubuntu8.1
Architecture: amd64
Date: Thu Jun 27 11:59:39 2013
InstallationDate: Installed on 2013-04-02 (86 days ago)
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
MarkForUpload: True
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: bash
UpgradeStatus: Upgraded to raring on 2013-06-23 (3 days ago)

Revision history for this message
Yuan Song (ysong) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.