From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,55f67640f3c703c0,start X-Google-Attributes: gidf678f,public From: chris@cs.uwa.oz.au (chris mcdonald) Subject: DEC/OSF1 assembler dies if fd=0 is closed Date: 1995/04/11 Message-ID: #1/1 X-Deja-AN: 100181237 organization: The University of Western Australia, Department of Computer Science keywords: gcc only newsgroups: comp.unix.osf.misc I'm afraid that I don't read this newsgroup very often, so this may be well known. When using gcc (2.6.*) on our DEC Alpha OSF1v2, I've found that if file descriptor 0 has been closed before the assembler is (eventually) invoked, the assembler will choke with a useless error such as: as1: Error: , line 0: Obsolete or corrupt binasm file: /tmp/ctmaaagAoa As this only occurs when using gcc (and not DEC's cc) I suspect it has something to do with gcc's default use of the -pipe switch under OSF. I only discovered this (eventually) because gcc was being invoked from a daemon which had fd=0,1,2 all closed. The problem did not occur on our Suns. The program below demonstrates the problem - if invoked with any arguments the assembler will fail. _______________________________________________________________________________ Chris McDonald EMAIL: chris@cs.uwa.edu.au Department of Computer Science WWW: http://www.cs.uwa.edu.au/ The University of Western Australia PHONE: ((+61) 09) 380 2533 Crawley, Western Australia, 6907 FAX: ((+61) 09) 380 1089 #include #include #define CC_PATH "/bin/cc" #define GCC_PATH "/usr/gnu/bin/gcc" int main(argc, argv) int argc; char **argv; { extern char *strrchr(); char *argv0; char *args[8]; int ac, pid, status; argv0 = (argv0 = strrchr(argv[0],'/')) ? argv0+1 : argv[0]; argc--; argv++; ac = 0; args[ac++] = "gcc"; switch (pid = (int)fork()) { case -1 : (void)fprintf(stderr,"%s: cannot fork\n",argv0); status = 1; break; case 0 : args[ac++] = "-c"; args[ac++] = "-o"; args[ac++] = "try.o"; args[ac++] = "try.c"; args[ac++] = (char *)NULL; { char **av = args; while(*av) (void)fprintf(stderr,"%s ", *av++); (void)fputc('\n',stderr); } if(argc > 0) (void)close(0); (void)execv(GCC_PATH, args); exit(1); break; default : while(wait(&status) != pid) /* wait for child to exit */ ; status = (status >> 8)&0177; break; } (void)fprintf(stderr,"%s exit(%d)\n", args[0], status); return(status); exit(status); }