Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bcstec!sleepy!allyn From: allyn@sleepy.UUCP (Mark Allyn) Newsgroups: comp.unix.questions Subject: errno Keywords: errno Message-ID: <212@sleepy.UUCP> Date: 12 Jun 91 14:26:45 GMT Organization: Boeing Computer Services, Seattle Lines: 37 I need to be able to take what is printed when you call perror and put it into a string variable to be used in a c program. I know that the errno variable is an external variable which points to some internal table in the kernel called sys_errlist. Is there some way of getting at that table so that I can get at the error messages? I tried the following logical solution after RTFM but it did not work (it got a seg fault) goo.c ______________________________________________________ #include #include #include #include #include #include main() { extern char **sys_errlist; FILE *fpp; int ctr1; fpp=fopen("/goo","w"); perror(""); printf("errno is %d\n",errno); printf("%d\n",(int)*(sys_errlist+errno)); } _____________________________________________________ I compiled and linkded this program with cc -g goo.c