From: Andrea M. <and...@au...> - 2022-11-14 08:17:19
|
When I use this script: #!/usr/bin/perl -w use strict; use IPC::Open2; use IO::Pty; my $pid; my $out; my $in; $in = new IO::Pty; $out = $in->slave; $pid = open2 ($out, $in, './a.out'); while (<$out>) { print $_; } with this C program (compiled to a.out): #include <stdio.h> #include <unistd.h> int main () { printf ("isatty 0 = %d, 1 = %d, 2 = %d\n", isatty (0), isatty (1), isatty (2)); } I get: isatty 0 = 0, 1 = 0, 2 = 1 That means that the pseudo-terminal doesn't convince the isatty function from glibc that it is a terminal (except for stderr that open2 does not redirect). That has unpleasant consequences, such as my C programs using block buffering instead of line buffering when piped to that Perl script - avoiding that is the only reason I tried IO::Pty. Am I doing something wrong? Andrea Monaco |