本文整理汇总了C++中errnoAbort函数的典型用法代码示例。如果您正苦于以下问题:C++ errnoAbort函数的具体用法?C++ errnoAbort怎么用?C++ errnoAbort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了errnoAbort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tcpCountServer
void tcpCountServer(char *portName)
/* tcpCountServer - A server that just returns a steadily increasing stream of numbers.
* This one is based on tcp */
{
int port = atoi(portName);
int ear, socket, size;
char buf[1024];
int count = 0;
struct timeval startTime, tv;
struct countMessage sendMessage, receiveMessage;
ear = netAcceptingSocket(port, 100);
gettimeofday(&startTime, NULL);
for (;;)
{
socket = netAccept(ear);
if (socket < 0)
errnoAbort("Couldn't accept first");
size = netReadAll(socket, &receiveMessage, sizeof(receiveMessage));
if (size < sizeof(receiveMessage))
continue;
gettimeofday(&tv, NULL);
sendMessage.time = timeDiff(&startTime, &tv);
sendMessage.echoTime = receiveMessage.time;
sendMessage.count = ++count;
sendMessage.message = receiveMessage.message + 256;
write(socket, &sendMessage, sizeof(sendMessage));
close(socket);
if (size < 0)
errnoAbort("Couldn't read first");
if (!receiveMessage.message)
break;
}
printf("All done after %d\n", count);
}
示例2: plProcSetup
static void plProcSetup(struct plProc* proc, int stdinFd, int stdoutFd, int stderrFd)
/* setup signal, error handling, and file descriptors after fork */
{
/* Optionally treat a closed pipe as an EOF rather than getting SIGPIPE */
if (signal(SIGPIPE, ((proc->pl->options & pipelineSigpipe) ? SIG_DFL : SIG_IGN)) == SIG_ERR)
errnoAbort("error ignoring SIGPIPE");
if (setpgid(getpid(), proc->pl->groupLeader) != 0)
errnoAbort("error from setpgid(%d, %d)", getpid(), proc->pl->groupLeader);
/* child, first setup stdio files */
if (stdinFd != STDIN_FILENO)
{
if (dup2(stdinFd, STDIN_FILENO) < 0)
errnoAbort("can't dup2 to stdin");
}
if (stdoutFd != STDOUT_FILENO)
{
if (dup2(stdoutFd, STDOUT_FILENO) < 0)
errnoAbort("can't dup2 to stdout");
}
if (stderrFd != STDERR_FILENO)
{
if (dup2(stderrFd, STDERR_FILENO) < 0)
errnoAbort("can't dup2 to stderr");
}
closeNonStdDescriptors();
}
示例3: mustMkstemp
int mustMkstemp(char tempFileName[PATH_LEN])
/* Fill in temporary file name with name of a tmp file and return open file handle.
* Also set permissions to something better. */
{
int fd = mkstemp(tempFileName);
if (fd == -1)
errnoAbort("Couldn't make temp file %s", tempFileName);
if (fchmod(fd, 0664) == -1)
errnoAbort("Couldn't change permissions on temp file %s", tempFileName);
return fd;
}
示例4: errnoAbort
char *mustReadSymlink(char *path)
/* Read symlink or abort. Checks that path is a symlink.
FreeMem the returned value. */
{
struct stat sb;
if (lstat(path, &sb) == -1)
errnoAbort("lstat failure on %s", path);
if ((sb.st_mode & S_IFMT) != S_IFLNK)
errnoAbort("path %s not a symlink.", path);
return mustReadSymlinkExt(path, &sb);
}
示例5: copyOpenFile
void copyOpenFile(FILE *inFh, FILE *outFh)
/* copy an open stdio file */
{
int c;
while ((c = fgetc(inFh)) != EOF)
fputc(c, outFh);
if (ferror(inFh))
errnoAbort("file read failed");
if (ferror(outFh))
errnoAbort("file write failed");
}
示例6: touchFileFromFile
void touchFileFromFile(const char *oldFile, const char *newFile)
/* Set access and mod time of newFile from oldFile. */
{
struct stat buf;
if (stat(oldFile, &buf) != 0)
errnoAbort("stat failed on %s", oldFile);
struct utimbuf puttime;
puttime.modtime = buf.st_mtime;
puttime.actime = buf.st_atime;
if (utime(newFile, &puttime) != 0)
errnoAbort("utime failed on %s", newFile);
}
示例7: mustRemove
void mustRemove(char *path)
/* Remove file or die trying */
{
int err = remove(path);
if (err < 0)
errnoAbort("Couldn't remove %s", path);
}
示例8: mustRename
void mustRename(char *oldName, char *newName)
/* Rename file or die trying. */
{
int err = rename(oldName, newName);
if (err < 0)
errnoAbort("Couldn't rename %s to %s", oldName, newName);
}
示例9: safeGetOne
boolean safeGetOne(char *source, char *dest)
/* Fetch file from source to tmp file. When fetch
* is done rename temp file to dest and return TRUE. */
{
struct dyString *command = dyStringNew(0);
boolean ok = TRUE;
int err;
dyStringClear(command);
dyStringPrintf(command, "wget -nv -O %s '%s'",
tmpName, source);
verbose(2, "%s\n", command->string);
if ((err = system(command->string)) != 0)
{
fprintf(fLog, "Error %d on %s\n", err, command->string);
warn("Error %d on %s", err, command->string);
++errCount;
if (errCount > maxErrs)
errAbort("Aborting after %d wget errors", errCount);
ok = FALSE;
}
verbose(2, "wget returned %d\n", err);
/* Rename file to proper name */
if (ok)
{
if ((err = rename(tmpName, dest)) < 0)
{
fprintf(fLog, "Couldn't rename %s to %s\n", tmpName, dest);
errnoAbort("Couldn't rename %s to %s", tmpName, dest);
}
}
dyStringFree(&command);
return ok;
}
示例10: copyFile
void copyFile(char *source, char *dest)
/* Copy file from source to dest. */
{
int bufSize = 64*1024;
char *buf = needMem(bufSize);
int bytesRead;
int s, d;
s = open(source, O_RDONLY);
if (s < 0)
errAbort("Couldn't open %s. %s\n", source, strerror(errno));
d = creat(dest, 0777);
if (d < 0)
{
close(s);
errAbort("Couldn't open %s. %s\n", dest, strerror(errno));
}
while ((bytesRead = read(s, buf, bufSize)) > 0)
{
if (write(d, buf, bytesRead) < 0)
errAbort("Write error on %s. %s\n", dest, strerror(errno));
}
close(s);
if (close(d) != 0)
errnoAbort("close failed");
freeMem(buf);
}
示例11: moreMimeBuf
static void moreMimeBuf(struct mimeBuf *b)
{
int bytesRead = 0, bytesToRead = 0;
if (b->blen > 1)
{
int r = b->eoi - b->i;
memmove(b->buf, b->i, r);
b->eoi = b->buf+r;
}
else
{
b->eoi = b->buf;
}
b->i = b->buf+0;
bytesToRead = b->eom - b->eoi;
while (bytesToRead > 0)
{
bytesRead = read(b->d, b->eoi, bytesToRead);
if (bytesRead < 0)
errnoAbort("moreMimeBuf: error reading MIME input descriptor");
b->eoi += bytesRead;
if (bytesRead == 0)
break;
bytesToRead = bytesToRead - bytesRead;
}
setEopMB(b);
setEodMB(b);
//debug
//fprintf(stderr,"post-moreMime dumpMB: ");
//dumpMB(b); //debug
}
示例12: plProcExecChild
static void plProcExecChild(struct plProc* proc, int stdinFd, int stdoutFd, int stderrFd)
/* child part of process startup. */
{
plProcSetup(proc, stdinFd, stdoutFd, stderrFd);
execvp(proc->cmd[0], proc->cmd);
errnoAbort("exec failed: %s", proc->cmd[0]);
}
示例13: pipelineExecProc
static int pipelineExecProc(struct pipeline* pl, struct plProc *proc,
int prevStdoutFd, int stdinFd, int stdoutFd, int stderrFd,
void *otherEndBuf, size_t otherEndBufSize)
/* start a process in the pipeline, return the stdout fd of the process */
{
/* determine stdin/stdout to use */
int procStdinFd, procStdoutFd;
if (proc == pl->procs)
procStdinFd = stdinFd; /* first process in pipeline */
else
procStdinFd = prevStdoutFd;
if (proc->next == NULL)
procStdoutFd = stdoutFd; /* last process in pipeline */
else
prevStdoutFd = pipeCreate(&procStdoutFd);
/* start process */
if ((proc->pid = fork()) < 0)
errnoAbort("can't fork");
if (proc->pid == 0)
{
if (otherEndBuf != NULL)
plProcMemWrite(proc, procStdoutFd, stderrFd, otherEndBuf, otherEndBufSize);
else
plProcExecChild(proc, procStdinFd, procStdoutFd, stderrFd);
}
/* don't leave intermediate pipes open in parent */
if (proc != pl->procs)
safeClose(&procStdinFd);
if (proc->next != NULL)
safeClose(&procStdoutFd);
return prevStdoutFd;
}
示例14: samToOpenBed
void samToOpenBed(char *samIn, FILE *f)
/* Like samToOpenBed, but the output is the already open file f. */
{
samfile_t *sf = samopen(samIn, "r", NULL);
bam_header_t *bamHeader = sf->header;
bam1_t one;
ZeroVar(&one);
int err;
while ((err = samread(sf, &one)) >= 0)
{
int32_t tid = one.core.tid;
if (tid < 0)
continue;
char *chrom = bamHeader->target_name[tid];
// Approximate here... can do better if parse cigar.
int start = one.core.pos;
int size = one.core.l_qseq;
int end = start + size;
boolean isRc = (one.core.flag & BAM_FREVERSE);
char strand = '+';
if (isRc)
{
strand = '-';
reverseIntRange(&start, &end, bamHeader->target_len[tid]);
}
fprintf(f, "%s\t%d\t%d\t.\t0\t%c\n", chrom, start, end, strand);
}
if (err < 0 && err != -1)
errnoAbort("samread err %d", err);
samclose(sf);
}
示例15: rawKeyIn
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("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;
}