error(1) does not work when not attached to a terminal -- ammended

zemon at felix.UUCP zemon at felix.UUCP
Sat May 26 06:09:00 AEST 1984


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



More information about the Comp.bugs.4bsd.ucb-fixes mailing list