[OpenWrt-Devel] stdout and putchar() behavior in musl

Ram Chandra Jangir rjangi at codeaurora.org
Thu Mar 31 03:13:06 EDT 2016


Thanks,

Even if I enter new line it does not help,  and these new lines(along with input character) comes as part of output after program exit only.

Thanks,
Ram

-----Original Message-----
From: Naresh Kumar Mehta [mailto:naresh at codeaurora.org] 
Sent: Thursday, March 31, 2016 12:31 PM
To: 'Arjen de Korte' <arjen+openwrt at de-korte.org>; openwrt-devel at lists.openwrt.org
Cc: 'Ram Chandra Jangir' <rjangi at codeaurora.org>
Subject: RE: [OpenWrt-Devel] stdout and putchar() behavior in musl

Thanks for your comments. Unfortunately flush(stdout) didn't help.

Thanks,
Naresh

-----Original Message-----
From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org] On Behalf Of Arjen de Korte
Sent: Wednesday, March 30, 2016 4:58 PM
To: openwrt-devel at lists.openwrt.org
Subject: Re: [OpenWrt-Devel] stdout and putchar() behavior in musl

Citeren Ram Chandra Jangir <rjangi at codeaurora.org>:

> Hi,
>
> Did anyone observed stdout and putchar() behavior differences between 
> musl & uClibc?
>
> I have below code snippet :
>
> int main(void){
> 	int c;
> 	while((c=getchar())!= 'e')     {
> 		putchar(c+1);
> 	}
> 	return 0;
> }
>
> When I use uClibc/gcc, I can see writing c+1 from putchar() happening 
> immediately. But when I use musl, character(c+1) gets printed on 
> console only if I exit from the program by entering 'e'.
> I guess printing character using putchar family on stdio is having 
> bug(or different implementation) in musl. Has anybody faced this 
> issue? Any workaround?

Apparently in uClibc stdout is unbuffered and in musl it is buffered.  
Either is allowed in the C-standard (it is  not specified) so this is not a bug. If you want each character to be output immediately, you probably need to add flush(stdout).
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list