Bruno Haible <[email protected]> writes:
> So, if I understand it correctly:
> - glibc considers /dev/full to be non-interactive,
> - musl libc considers /dev/full to be interactive.
>
> Can you show (via 'strace') the system calls related to fd = 1,
> that make this determination, in the two cases?
Well, musl does perform the check and sees it isn't a tty. However, it
still doesn't buffer the output. Here is a test program:
$ cat main.c
#include <stdio.h>
#include <unistd.h>
int
main (void)
{
printf ("%s %s\n", "hello", "1");
sleep (1);
printf ("%s %s\n", "hello", "2");
return 0;
}
Here is it running on musl (trimming some obviously irrelevant calls
like brk and mmap):
$ gcc main.c && strace ./a.out > /dev/full
[...]
ioctl(1, TIOCGWINSZ, 0xbf9d08e8) = -1 ENOTTY (Not a tty)
writev(1, [{iov_base="hello 1", iov_len=7}, {iov_base="\n", iov_len=1}], 2)
= -1 ENOSPC (No space left on device)
nanosleep({tv_sec=1, tv_nsec=0}, 0xbf9d0ae0) = 0
writev(1, [{iov_base="hello 2\n", iov_len=8}, {iov_base=NULL, iov_len=0}],
2) = -1 ENOSPC (No space left on device)
exit_group(0) = ?
+++ exited with 0 +++
And on glibc:
$ gcc main.c && strace ./a.out > /dev/full
[...]
fstat(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(0x1, 0x7), ...}) = 0
ioctl(1, TCGETS2, 0x7ffdad7df420) = -1 ENOTTY (Inappropriate ioctl
for device)
brk(NULL) = 0x1c9d9000
brk(0x1c9fb000) = 0x1c9fb000
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffdad7df7f0) = 0
write(1, "hello 1\nhello 2\n", 16) = -1 ENOSPC (No space left on
device)
exit_group(0) = ?
+++ exited with 0 +++
So both use isatty (implemented through differing, but reasonable
ioctls) and see that standard output isn't a terminal.
Collin