Next: , Previous: Memory management, Up: libnix.a

6.4.5 Standard I/O - where stdin, stdout, stderr come from

2 of the 3 standard I/O streams are no real problem:

Both streams are managed by the OS and the library need not take much care about them. But ‘stderr’ is a different thing since there is no ‘Errput()’ ;-) function. So ‘stderr’ is handled as follows:

  1. If ‘process->pr_CES’ is set, this value is taken. There are not much shells that set this value so most of the time this leads to NULL.
  2. If this didn't work and your program was started from CLI the library opens ‘Open("*",MODE_NEWFILE)’. This opens the last interactive terminal attached to stdout, i.e. if you use the normal Amiga shell and redirect your output to a file you get the terminal, if you redirect your output to ‘NIL:’ you get ‘NIL:’.
  3. If this didn't work too (you never know) or your program was started from WB you simply get the same stream as in ‘stdout’.