But it is so weak...system "strace -o /tmp/strace.out -e open,read more @ARGV"; open my $trace, "/tmp/strace.out" or die; my $last = ''; while (<$trace>) { if (/read\(2,\s*"(.*)",\s*1\)\s*=\s*1$/) { $last = $1; } } print "exited with key >$last<\n";
update: How about Ctrl-C?
system "strace -o /tmp/strace.out -e open,read more @ARGV"; open my $trace, "/tmp/strace.out" or die; my $last = ''; while (<$trace>) { if (/read\(2,\s*"(.*)",\s*1\)\s*=\s*1$/ or /--- SIG(\w+)/) { $last = $1; } } print "exited with key >$last<\n";
In reply to Re: How to know whether user terminates system("$cmd|more") with q or not?
by salva
in thread How to know whether user terminates system("$cmd|more") with q or not?
by PerlOnTheWay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |