506df3831ad1f7da0dbf435441f06217c74b795c hiram Thu Oct 28 13:23:03 2010 -0700 obscure error messages need to identify themselves diff --git src/lib/osunix.c src/lib/osunix.c index f75c363..8610091 100644 --- src/lib/osunix.c +++ src/lib/osunix.c @@ -64,39 +64,39 @@ } void uglyfBreak() /* Go into debugger. */ { static char *nullPt = NULL; nullPt[0] = 0; } char *getCurrentDir() /* Return current directory. Abort if it fails. */ { static char dir[PATH_LEN]; if (getcwd( dir, sizeof(dir) ) == NULL ) - errnoAbort("can't get current directory"); + errnoAbort("getCurrentDir: can't get current directory"); return dir; } void setCurrentDir(char *newDir) /* Set current directory. Abort if it fails. */ { if (chdir(newDir) != 0) - errnoAbort("can't to set current directory: %s", newDir); + errnoAbort("setCurrentDir: can't to set current directory: %s", newDir); } boolean maybeSetCurrentDir(char *newDir) /* Change directory, return FALSE (and set errno) if fail. */ { return chdir(newDir) == 0; } struct slName *listDir(char *dir, char *pattern) /* Return an alphabetized list of all files that match * the wildcard pattern in directory. */ { struct slName *list = NULL, *name; struct dirent *de; DIR *d; @@ -484,76 +484,76 @@ /* Test // removal */ assert(sameString(simplifyPathToDir("//"),"/")); assert(sameString(simplifyPathToDir("//../"),"/..")); assert(sameString(simplifyPathToDir("a//b///c"),"a/b/c")); assert(sameString(simplifyPathToDir("a/b///"),"a/b")); } #endif /* DEBUG */ char *getUser() /* Get user name */ { uid_t uid = geteuid(); struct passwd *pw = getpwuid(uid); if (pw == NULL) - errnoAbort("can't get user name for uid %d", (int)uid); + errnoAbort("getUser: can't get user name for uid %d", (int)uid); return pw->pw_name; } int mustFork() /* Fork or abort. */ { int childId = fork(); if (childId == -1) - errnoAbort("Unable to fork"); + errnoAbort("mustFork: Unable to fork"); return childId; } int rawKeyIn() /* Read in an unbuffered, unechoed character from keyboard. */ { struct termios attr; tcflag_t old; char c; /* Set terminal to non-echoing non-buffered state. */ if (tcgetattr(STDIN_FILENO, &attr) != 0) errAbort("Couldn't do tcgetattr"); old = attr.c_lflag; attr.c_lflag &= ~ICANON; attr.c_lflag &= ~ECHO; if (tcsetattr(STDIN_FILENO, TCSANOW, &attr) == -1) errAbort("Couldn't do tcsetattr"); /* Read one byte */ if (read(STDIN_FILENO,&c,1) != 1) - errnoAbort("I/O error"); + errnoAbort("rawKeyIn: I/O error"); /* Put back terminal to how it was. */ attr.c_lflag = old; if (tcsetattr(STDIN_FILENO, TCSANOW, &attr) == -1) errAbort("Couldn't do tcsetattr2"); return c; } boolean isPipe(int fd) /* determine in an open file is a pipe */ { struct stat buf; if (fstat(fd, &buf) < 0) - errnoAbort("fstat failed"); + errnoAbort("isPipe: fstat failed"); return S_ISFIFO(buf.st_mode); } static void execPStack(pid_t ppid) /* exec pstack on the specified pid */ { char *cmd[3], pidStr[32]; safef(pidStr, sizeof(pidStr), "%ld", (long)ppid); cmd[0] = "pstack"; cmd[1] = pidStr; cmd[2] = NULL; // redirect stdout to stderr if (dup2(2, 1) < 0) errAbort("dup2 failed");