This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

printf and line buffering


Hi there,

I have been porting newlib to run on my OS, it runs really well, but I am having a problem and can't work out what I am doing wrong.

Trying to write a shell, I want to print "Mort$ " without a line break, but printf won't do this. I have been going through the newlib source and found some comments, the first was about defaulting to line buffered if I don't supply an fcntl system call, so I implemented one, the second was that as per ANSI standard ttys are by default line buffered.

I can't work out how to switch line buffering off. I have been tracing the system calls to my OS, I have isatty being called (to which my OS responds 1 (yes)) but no fcntl - so i guess I am not setting flags incorrectly. Also, putchar works fine, it puts a char immediatly.

I have tried "setvbuf(stdout, NULL, _IONBF, 0);" but that didn't work, searching google I haven't found any answers that work. I also do this, to make my tty driver work properly:

  tcgetattr(STDIN_FILENO, &saved);
  t = saved;
  t.c_lflag &= ~ICANON;
  t.c_lflag &= ~ECHO;
  t.c_lflag &= ~ECHOCTL;
  t.c_cc[VMIN] = 1;
  t.c_cc[VTIME] = 0;

The thing is, it compiles and works fine on both cygwin and freebsd.

If anyone has any ideas, or if I need to provide more information, please let me know.

Thanks,
Andrew

--
Mort - http://www.mort-os.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]