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!linus!vaxine!wjh12!genrad!decvax!ittvax!dcdwest!sdcsvax!bmcg!felix!zemon From: zemon@felix.UUCP Newsgroups: net.bugs.4bsd Subject: error(1) does not work when not attached to a terminal -- ammended Message-ID: <282@felix.UUCP> Date: Fri, 25-May-84 16:09:00 EDT Article-I.D.: felix.282 Posted: Fri May 25 16:09:00 1984 Date-Received: Mon, 28-May-84 06:06:56 EDT Organization: FileNet Corp., Costa Mesa, Ca. Lines: 57 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 17c39 < char *im_on; /* my tty name */ --- > char im_on[] = "/dev/tty"; /* my tty name */ 127,131c149,155 < 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) { > if ( (queryfile = fopen(im_on, "r")) == NULL){ > fprintf(stderr, > "%s: Can't open \"%s\" to query the user.\n", > processname, im_on); > exit(9); > } 132a157 > Submitted-by: Art Zemon FileNet Corp. ...!{ucbvax,decvax}!trwrb!felix!zemon (714)966-2344