[3013] in Athena Bugs

home help back first fref pref prev next nref lref last post

csh status variable seems to be coerced into a char

daemon@ATHENA.MIT.EDU (sethf@ATHENA.MIT.EDU)
Sun Aug 27 08:50:30 1989

From: <sethf@ATHENA.MIT.EDU>
Date: Sun, 27 Aug 89 08:50:10 -0400
To: bugs@ATHENA.MIT.EDU
SYSTEM = RT and VS2000, release 6.3B

	The variable "status" in csh, representing the exit status of a
program, seems to be coerced into the char type. All the documentation I
can find suggests it should be an integer.
	This is easily demonstrated by compiling the following program :

main(argc, argv)
    int argc;
    char **argv;
{
exit(atoi(argv[1]));
}
		

Call it exitstatus. Then do

exitstatus i ; echo $status

for various integer i (particulary 128, 256 and 257).

The problem also appears to occur in sh.

I encountered this problem in the following case:

Consider the execution of the C line :

status = system("/bin/mkdir /foo"); exit(status);

Suppose the user does not have write permission to /, so the directory
/foo cannot be created. In dbx, "status" was reportedly set to 256. But
the "status" variable in the shell was set to 0, indicating success.
This was on a standard 6.3B RT.

================
Seth Finkelstein
sethf@athena.mit.edu
sethf%athena.mit.edu@mit-eddie.UUCP
mit-eddie!mit-athena!sethf



home help back first fref pref prev next nref lref last post