(unix/C) "stty: stdin isn't a terminal" when using system() function -
we're reading file stdin file_buffer, , stepping method more.
as use system("stty cbreak -echo");, output prints "stty: stdin isn't terminal" , doesn't set our terminal settings asked for.
this problem exists when use standard in. if use file argument, program works fine -- terminal settings set, , there no error message.
so, okay: myprogram file1.txt
but not: myprogram < file1.txt
either way contents being read file_buffer before being used @ all. heck wrong using stty if we're taking input stdin??
when standard input file, isn't terminal, setting terminal attributes on stty's standard input won't work.
it sounds daft @ first, find can use either stdout or stderr input stty , adjust terminal. therefore:
system("stty cbreak -echo <&2"); is set terminal characteristics. if have gnu version of stty, use:
system("stty -f /dev/stderr cbreak -echo"); or substitute /dev/stdout or /dev/tty /dev/stderr. use of named devices instead of &2 in redirection in first variant.
Comments
Post a Comment