您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ unix_error函数代码示例

51自学网 2021-06-03 09:10:28
  C++
这篇教程C++ unix_error函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中unix_error函数的典型用法代码示例。如果您正苦于以下问题:C++ unix_error函数的具体用法?C++ unix_error怎么用?C++ unix_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了unix_error函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Sleep

unsigned int Sleep(unsigned int secs) {  unsigned int rc;  if ((rc = sleep(secs)) < 0) unix_error("Sleep error");  return rc;}
开发者ID:xibaohe,项目名称:tiny_server,代码行数:6,


示例2: Execve

void Execve(const char *filename, char *const argv[], char *const envp[]) {    if (execve(filename, argv, envp) < 0)	unix_error("Execve error");}
开发者ID:fffxj,项目名称:csapp,代码行数:5,


示例3: Sigfillset

void Sigfillset(sigset_t *set){     if (sigfillset(set) < 0)	unix_error("Sigfillset error");    return;}
开发者ID:fffxj,项目名称:csapp,代码行数:6,


示例4: Sem_init

void Sem_init(sem_t *sem, int pshared, unsigned int value) {    if (sem_init(sem, pshared, value) < 0)	unix_error("Sem_init error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例5: V

void V(sem_t *sem) {    if (sem_post(sem) < 0)	unix_error("V error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例6: Munmap

void Munmap(void *start, size_t length) {    if (munmap(start, length) < 0)	unix_error("munmap error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例7: Fputs

void Fputs(const char *ptr, FILE *stream) {    if (fputs(ptr, stream) == EOF)	unix_error("Fputs error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例8: Sigprocmask

void Sigprocmask(int method, sigset_t *mask, sigset_t *oldmask) {    if (sigprocmask(method, mask, oldmask)) {        unix_error("Sigprocmask error");    }}
开发者ID:athorhallsson,项目名称:tinyshell,代码行数:5,


示例9: Kill

void Kill(pid_t pid, int signum) {    if (kill(pid, signum) < 0) {        unix_error("Kill error");    }}
开发者ID:athorhallsson,项目名称:tinyshell,代码行数:5,


示例10: Sigemptyset

void Sigemptyset(sigset_t *mask) {    if (sigemptyset(mask) < 0) {        unix_error("Sigemptyset error");    }}
开发者ID:athorhallsson,项目名称:tinyshell,代码行数:5,


示例11: Sigaddset

void Sigaddset(sigset_t *mask, int signum) {    if (sigaddset(mask, signum) < 0) {        unix_error("Sigaddset error");    }}
开发者ID:athorhallsson,项目名称:tinyshell,代码行数:5,


示例12: sigtstp_handler

/* * sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever *     the user types ctrl-z at the keyboard. Catch it and suspend the *     foreground job by sending it a SIGTSTP.   */void sigtstp_handler(int sig) {    if (kill(-fgpid(jobs), SIGSTOP) == -1) unix_error("kill failed");    return;}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:10,


示例13: sigint_handler

/*  * sigint_handler - The kernel sends a SIGINT to the shell whenver the *    user types ctrl-c at the keyboard.  Catch it and send it along *    to the foreground job.   */void sigint_handler(int sig) {    if (kill(-fgpid(jobs), SIGINT) == -1) unix_error("kill failed");    return;}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:10,


示例14: Setpgid

void Setpgid(pid_t pid, pid_t pgid) {  int rc;  if ((rc = setpgid(pid, pgid)) < 0) unix_error("Setpgid error");  return;}
开发者ID:xibaohe,项目名称:tiny_server,代码行数:6,


示例15: Stat

void Stat(const char *filename, struct stat *buf) {    if (stat(filename, buf) < 0)	unix_error("Stat error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例16: do_bgfg

/*  * do_bgfg - Execute the builtin bg and fg commands */void do_bgfg(char **argv) {	int jid;	pid_t pid;	struct job_t* jobp = NULL;		//check for condition "bg " or "fg "	if(argv[1] == NULL){		printf("%s command requires PID or %%jobid argument/n", argv[0]);		return;	}		//jid %x	if(argv[1][0] == '%'){		jid = atoi(&argv[1][1]);		jobp = getjobjid(jobs, jid);		//check for the condition for invalid jid %x		if(jobp == NULL){			printf("%%%d: No such job/n", jid);			return;		}	}	//pid x	else if(isdigit(argv[1][0])){		pid = atoi(argv[1]);		jobp = getjobpid(jobs, pid);		//check for the condition for invalid pid x		if(jobp == NULL){			printf("(%d): No such process/n", pid);			return;		}	}	//check for the condition "bg a" or "fg a"	else{		printf("%s: argument must be a PID or %%jobid/n", argv[0]);		return;	}	//send signal to all the processes in the process group	if(kill(-(jobp->pid), SIGCONT) < 0){		unix_error("kill error");	}		//do work for background	if(!strcmp(argv[0], "bg")){		jobp->state = BG;		printf("[%d] (%d) %s", jobp->jid, jobp->pid, jobp->cmdline);	}	//do work for foreground	else if(!strcmp(argv[0], "fg")){		jobp->state = FG;		waitfg(jobp->pid);	}	//check for the condition "x 1"	else		unix_error("must be bg or fg");    return;}
开发者ID:vvv214,项目名称:icsLab,代码行数:68,


示例17: Fstat

void Fstat(int fd, struct stat *buf) {    if (fstat(fd, buf) < 0)	unix_error("Fstat error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例18: split_net

/* split a net file */static void split_net(void) {	FILE *input;	FILE *output;	int filename_len;	char *filename;	int open = 0;	input = Fopen(opt.in_file, "r");	/* make the output directory */	if ((mkdir(opt.out_dir, S_IRWXU | S_IRWXG | S_IRWXO) == -1)) {		if (errno != EEXIST) {			unix_error("mkdir failed");		}	}	/* very simple splitter */	while (Fgets(line, LINE_MAX, input) != NULL) {		/* find the net line */		if (strstr(line, "net") == line) {			/* get the chrom name */			if (sscanf(line, "net %s ", chrom) != 1) {				fprintf(stderr, "%s: Can't parse the following line:/n", prog);				fprintf(stderr, "%s", line);				exit(EXIT_FAILURE);			}			/* build the output filename */			filename_len = opt.out_dir_len + (int) strlen(chrom) + (int) strlen(opt.suffix) + 2;			filename = (char *) Malloc (filename_len * sizeof(char));						strcpy(filename, opt.out_dir);			strcat(filename, "/");			strcat(filename, chrom);			strcat(filename, opt.suffix);			/* close if necessary */			if (open) {				Fclose(output);			}			output = Fopen(filename, "w");			free(filename);			fprintf(output, "%s", line);			open = 1;			continue;		}		if (! open) {			fprintf(stderr, "Out of synch (didn't find net line?)/n");			exit(EXIT_FAILURE);		}		fprintf(output, "%s", line);	}	Fclose(input);}
开发者ID:ma-compbio,项目名称:RACA,代码行数:62,


示例19: Fclose

/****************************************** * Wrappers for the Standard I/O functions. ******************************************/void Fclose(FILE *fp) {    if (fclose(fp) != 0)	unix_error("Fclose error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:8,


示例20: Fclose

/* fclose, checking for erros */void Fclose(FILE *stream) {	if (fclose(stream) == EOF) {		unix_error("fclose failed");	}}
开发者ID:ma-compbio,项目名称:RACA,代码行数:6,


示例21: Fwrite

void Fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {    if (fwrite(ptr, size, nmemb, stream) < nmemb)	unix_error("Fwrite error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例22: unix_execvpe

CAMLprim value unix_execvpe(value path, value args, value env){  unix_error(ENOSYS, "execvpe", path);  return Val_unit;}
开发者ID:dhil,项目名称:ocaml-multicore,代码行数:5,


示例23: P

void P(sem_t *sem) {    if (sem_wait(sem) < 0)	unix_error("P error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例24: main

int main(int argc, char *argv[]){	int listenfd, connfd;	char hostname[MAXLINE], port[MAXLINE];	socklen_t clientlen;	struct sockaddr_storage clientaddr;	int acc_count = 0;	//if (strcmp(argv[2], "compute-0-29.local") == 0)	//{	printf("%s listening/n", argv[2]);	listenfd = Open_listenfd ("15618");	//}	sleep(5);	//int send_val = 5;	printf("Hostname is %s/n", argv[2]);	printf("Int got as %d/n", atoi(argv[1]));	if (strcmp(argv[2], "compute-0-29.local") == 0)	{		while (1)		{			clientlen = sizeof (clientaddr);			// accept connections 			connfd = Accept (listenfd, (SA *) & clientaddr, &clientlen);			Getnameinfo ((SA *) & clientaddr, clientlen, hostname, MAXLINE,					port, MAXLINE, 0);			printf ("Accepted connection from (%s, %s). Connfd is %d/n", hostname, port, connfd);			//newfd = (int *) malloc (sizeof (int));			//newfd = connfd;			// go serve this client! 			// pthread_create (&tid, NULL, doit, newfd);			acc_count++;			double send_double = 232.23;			int retval = Rio_writen (connfd, (void *)&send_double, sizeof(double));			if (retval < 0)			{   				printf("Rio_writen to %d encountered a problem./n", connfd);				unix_error ("Rio_writen error");			}   			retval = Rio_writen (connfd, (void *)&send_double, sizeof(double));			if (retval < 0)			{   				printf("Rio_writen to %d encountered a problem./n", connfd);				unix_error ("Rio_writen error");			}			int len = Rio_readn (connfd, (void *)&send_double, sizeof(double));			if (len < 0)			{				unix_error ("Rio_readlineb error");			}			printf("Host %s got len as %d and receive_val as %lf/n", argv[2], len, send_double);			len = Rio_readn (connfd, (void *)&send_double, sizeof(double));			if (len < 0)			{				unix_error ("Rio_readlineb error");			}			printf("Host %s got len as %d and receive_val as %lf/n", argv[2], len, send_double);			if (acc_count == 3)			{				printf("Accepted 3 connections./n");				break;			}		}	}	else	{		int serverfd = Open_clientfd ("10.22.1.241", "15618");		printf("In host %s, serverfd is %d/n", argv[2], serverfd);		double buf;		int len = Rio_readn (serverfd, (void *)&buf, sizeof(double));		if (len < 0)		{			unix_error ("Rio_readlineb error");		}		printf("Host %s got len as %d and buf as %lf/n", argv[2], len, buf);		len = Rio_readn (serverfd, (void *)&buf, sizeof(double));		if (len < 0)		{			unix_error ("Rio_readlineb error");		}		printf("Host %s got len as %d and buf as %lf/n", argv[2], len, buf);		buf = 99.104;//.........这里部分代码省略.........
开发者ID:abhishekjoshi2,项目名称:cuGP,代码行数:101,


示例25: Rio_writen

void Rio_writen(int fd, void *usrbuf, size_t n) {    if (rio_writen(fd, usrbuf, n) != n)	unix_error("Rio_writen error");}
开发者ID:LWilliamson1,项目名称:mycloud,代码行数:5,


示例26: main

/************** * Main routine **************/int main(int argc, char **argv){    int i;    char c;    char **tracefiles = NULL;  /* null-terminated array of trace file names */    int num_tracefiles = 0;    /* the number of traces in that array */    trace_t *trace = NULL;     /* stores a single trace file in memory */    range_t *ranges = NULL;    /* keeps track of block extents for one trace */    stats_t *libc_stats = NULL;/* libc stats for each trace */    stats_t *mm_stats = NULL;  /* mm (i.e. student) stats for each trace */    speed_t speed_params;      /* input parameters to the xx_speed routines */     int team_check = 1;  /* If set, check team structure (reset by -a) */    int run_libc = 0;    /* If set, run libc malloc (set by -l) */    int autograder = 0;  /* If set, emit summary info for autograder (-g) */    /* temporaries used to compute the performance index */    double secs, ops, util, avg_mm_util, avg_mm_throughput, p1, p2, perfindex;    int numcorrect;        /*      * Read and interpret the command line arguments      */    while ((c = getopt(argc, argv, "f:t:hvVgal")) != EOF) {        switch (c) {	case 'g': /* Generate summary info for the autograder */	    autograder = 1;	    break;        case 'f': /* Use one specific trace file only (relative to curr dir) */            num_tracefiles = 1;            if ((tracefiles = realloc(tracefiles, 2*sizeof(char *))) == NULL)		unix_error("ERROR: realloc failed in main");	    strcpy(tracedir, "./");             tracefiles[0] = strdup(optarg);            tracefiles[1] = NULL;            break;	case 't': /* Directory where the traces are located */	    if (num_tracefiles == 1) /* ignore if -f already encountered */		break;	    strcpy(tracedir, optarg);	    if (tracedir[strlen(tracedir)-1] != '/') 		strcat(tracedir, "/"); /* path always ends with "/" */	    break;        case 'a': /* Don't check team structure */            team_check = 0;            break;        case 'l': /* Run libc malloc */            run_libc = 1;            break;        case 'v': /* Print per-trace performance breakdown */            verbose = 1;            break;        case 'V': /* Be more verbose than -v */            verbose = 2;            break;        case 'h': /* Print this message */	    usage();            exit(0);        default:	    usage();            exit(1);        }    }	    /*      * Check and print team info      */    if (team_check) {	/* Students must fill in their team information */	if (!strcmp(team.teamname, "")) {	    printf("ERROR: Please provide the information about your team in mm.c./n");	    exit(1);	} else	    printf("Team Name:%s/n", team.teamname);	if ((*team.name1 == '/0') || (*team.id1 == '/0')) {	    printf("ERROR.  You must fill in all team member 1 fields!/n");	    exit(1);	} 	else	    printf("Member 1 :%s:%s/n", team.name1, team.id1);	if (((*team.name2 != '/0') && (*team.id2 == '/0')) ||	    ((*team.name2 == '/0') && (*team.id2 != '/0'))) { 	    printf("ERROR.  You must fill in all or none of the team member 2 ID fields!/n");	    exit(1);	}	else if (*team.name2 != '/0')	    printf("Member 2 :%s:%s/n", team.name2, team.id2);    }    /*      * If no -f command line arg, then use the entire set of tracefiles      * defined in default_traces[]     */    if (tracefiles == NULL) {        tracefiles = default_tracefiles;        num_tracefiles = sizeof(default_tracefiles) / sizeof(char *) - 1;//.........这里部分代码省略.........
开发者ID:gz,项目名称:cslab,代码行数:101,


示例27: Sigprocmask

void Sigprocmask(int how, const sigset_t *set, sigset_t *oldset){    if (sigprocmask(how, set, oldset) < 0)	unix_error("Sigprocmask error");    return;}
开发者ID:fffxj,项目名称:csapp,代码行数:6,


示例28: printf

/* * read_trace - read a trace file and store it in memory */static trace_t *read_trace(char *tracedir, char *filename){    FILE *tracefile;    trace_t *trace;    char type[MAXLINE];    char path[MAXLINE];    unsigned index, size;    unsigned max_index = 0;    unsigned op_index;    if (verbose > 1)	printf("Reading tracefile: %s/n", filename);    /* Allocate the trace record */    if ((trace = (trace_t *) malloc(sizeof(trace_t))) == NULL)	unix_error("malloc 1 failed in read_trance");	    /* Read the trace file header */    strcpy(path, tracedir);    strcat(path, filename);    if ((tracefile = fopen(path, "r")) == NULL) {	sprintf(msg, "Could not open %s in read_trace", path);	unix_error(msg);    }    fscanf(tracefile, "%d", &(trace->sugg_heapsize)); /* not used */    fscanf(tracefile, "%d", &(trace->num_ids));         fscanf(tracefile, "%d", &(trace->num_ops));         fscanf(tracefile, "%d", &(trace->weight));        /* not used */        /* We'll store each request line in the trace in this array */    if ((trace->ops = 	 (traceop_t *)malloc(trace->num_ops * sizeof(traceop_t))) == NULL)	unix_error("malloc 2 failed in read_trace");    /* We'll keep an array of pointers to the allocated blocks here... */    if ((trace->blocks = 	 (char **)malloc(trace->num_ids * sizeof(char *))) == NULL)	unix_error("malloc 3 failed in read_trace");    /* ... along with the corresponding byte sizes of each block */    if ((trace->block_sizes = 	 (size_t *)malloc(trace->num_ids * sizeof(size_t))) == NULL)	unix_error("malloc 4 failed in read_trace");        /* read every request line in the trace file */    index = 0;    op_index = 0;    while (fscanf(tracefile, "%s", type) != EOF) {	switch(type[0]) {	case 'a':	    fscanf(tracefile, "%u %u", &index, &size);	    trace->ops[op_index].type = ALLOC;	    trace->ops[op_index].index = index;	    trace->ops[op_index].size = size;	    max_index = (index > max_index) ? index : max_index;	    break;	case 'r':	    fscanf(tracefile, "%u %u", &index, &size);	    trace->ops[op_index].type = REALLOC;	    trace->ops[op_index].index = index;	    trace->ops[op_index].size = size;	    max_index = (index > max_index) ? index : max_index;	    break;	case 'f':	    fscanf(tracefile, "%ud", &index);	    trace->ops[op_index].type = FREE;	    trace->ops[op_index].index = index;	    break;	default:	    printf("Bogus type character (%c) in tracefile %s/n", 		   type[0], path);	    exit(1);	}	op_index++;	    }    fclose(tracefile);    assert(max_index == trace->num_ids - 1);    assert(trace->num_ops == op_index);        return trace;}
开发者ID:gz,项目名称:cslab,代码行数:85,


示例29: Sigaddset

void Sigaddset(sigset_t *set, int signum){    if (sigaddset(set, signum) < 0)	unix_error("Sigaddset error");    return;}
开发者ID:fffxj,项目名称:csapp,代码行数:6,


示例30: Poll

int Poll(struct pollfd *fdarray, unsigned long nfds, int timeout) {  int rc;  if ((rc = poll(fdarray, nfds, timeout)) == -1) unix_error("poll Unix error");  return rc;}
开发者ID:xibaohe,项目名称:tiny_server,代码行数:5,



注:本文中的unix_error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ unix_ipc_error函数代码示例
C++ units函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。