Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site felix.UUCP Path: utzoo!watmath!clyde!akgua!sdcsvax!bmcg!felix!zemon From: zemon@felix.UUCP Newsgroups: net.bugs.4bsd Subject: error(1) does not work unless attached to a terminal Message-ID: <280@felix.UUCP> Date: Thu, 24-May-84 19:49:49 EDT Article-I.D.: felix.280 Posted: Thu May 24 19:49:49 1984 Date-Received: Fri, 1-Jun-84 01:35:23 EDT Organization: FileNet Corp., Costa Mesa, Ca. Lines: 70 Full-Name: Art Zemon 714-966-2344 UUCP-address: ...!{ decvax | ucbvax }!trwrb!felix!zemon Index: ucb/error/errormain.c 4.2BSD Fix ---------- Description: Error(1) will not work if it is run when not attached to a terminal. For example, error(1) will fail when run under control of at(1) or the MDQS batch(1) command. The reason is that error(1) always attempts to open /dev/tty. Error(1) exits if the open fails. It is only necessary to open /dev/tty if the -q option is given. This applies to error(1) as distributed with 4.2bsd. It probably also applies to earlier versions. The sccsid line from out version of error(1) is: *sccsid = "@(#)errormain.c 1.4 (Berkeley) 5/4/82"; Repeat-By: Execute something like this within an MDQS batch queue using the C shell: ( cc ... |& error > error-stdout ) >& error-stderr "error-stdout" should contain standard status information from error(1) and "error-stderr" should be empty. Instead, "error-stdout" will be empty and "error-stderr" will contain the message "error: Can't open /dev/tty to query the user.". Fix: RCS file: RCS/errormain.c,v retrieving revision 1.1 diff -r1.1 errormain.c 0a1,11 > /* > * $Log: errormain.c,v $ > * Revision 1.2 84/05/24 15:55:16 zemon > * Don't open /dev/tty unless -q is specified. > * This is necessary to allow running error under MDQS batch. > * If the change is not installed, the attempted open of /dev/tty > * fails when the MDQS daemon is not attached to a terminal. > * > */ > > #ifndef lint 1a13,15 > static char rcsid[] = "$Header: errormain.c,v 1.2 84/05/24 15:55:16 zemon Exp $"; > #endif > 127,131c141,148 < im_on = "/dev/tty"; < if ( (queryfile = fopen(im_on, "r")) == NULL){ < fprintf(stderr,"%s: Can't open \"%s\" to query the user.\n", < processname, im_on); < exit(9); --- > if (query) { > im_on = "/dev/tty"; > if ( (queryfile = fopen(im_on, "r")) == NULL){ > fprintf(stderr, > "%s: Can't open \"%s\" to query the user.\n", > processname, im_on); > exit(9); > } 132a150 > Submitted-by: Art Zemon FileNet Corp. ...!{ucbvax,decvax}!trwrb!felix!zemon (714)966-2344