home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / amiga / programm / 12833 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  2.3 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!adastra!mbs
  2. From: mbs@adastra.cvl.va.us (Michael B. Smith)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Console file handlers from within a Shell started program
  5. Distribution: world
  6. Message-ID: <mbs.0wou@adastra.cvl.va.us>
  7. References: <1992Aug11.080104.3354@syma.sussex.ac.uk> <1b7ea705.ARN22d0@prolix.pub.uu.oz.au> <14545@borg.cs.unc.edu> <1992Aug18.095812.27466@syma.sussex.ac.uk>
  8. X-NewsSoftware: GRn 1.16f (beta) by Mike Schwartz & Michael B. Smith
  9. Date: 28 Aug 92 17:28:03 EDT
  10. Organization: Private UUCP Node
  11. Lines: 47
  12.  
  13. In article <1992Aug18.095812.27466@syma.sussex.ac.uk> mpue2@syma.sussex.ac.uk (James E. Talbut) writes:
  14. > method (that I think is better than any of the suggestions) but I have
  15. > also found the DOS 2.0 has stderr.
  16. >
  17. > Do any of the shells for the ami' actually use it?
  18. > With redirection?
  19.  
  20. No, they don't use it because it isn't completely supported. There is a field
  21. in the Process structure for a standard error file, but AmigaDOS doesn't use
  22. it on V37.
  23.  
  24. If you are going to try to use it, then code defensively, eg:
  25.  
  26.                 struct Process *myproc = (struct Process *) FindTask (NULL);
  27.                 BPTR std_input  = myproc->pr_CIS;   // Input()
  28.                 BPTR std_output = myproc->pr_COS;   // Output()
  29.                 BPTR std_error  = myproc->pr_CES;
  30.                 int  close_err  = 0;
  31.                 int  clear_err  = 0;
  32.  
  33.                 if (!std_error) {
  34.                         clear_err = 1;
  35. #if 0
  36.                         // if you want it to be the same as stdout
  37.                         std_error = std_output;
  38. #else
  39.                         // if you want it to be console output
  40.                         std_error = Open ("CONSOLE:", MODE_OLDFILE);
  41.                         close_err = 1;
  42. #endif
  43.                         myproc->pr_CES = std_error;
  44.                 }
  45.                 ...
  46.                 ...stuff...
  47.                 ...
  48.                 if (close_err) {
  49.                         Close (std_err);
  50.                         close_err = 0;
  51.                 }
  52.                 if (clear_err) {
  53.                         myproc->pr_CES = NULL;
  54.                         std_error = NULL;
  55.                         clear_err = 0;
  56.                 }
  57. --
  58.   //   Michael B. Smith
  59. \X/    mbs@adastra.cvl.va.us  -or-  uunet.uu.net!virginia.edu!adastra!mbs
  60.