随笔分类 -  linux c

摘要:1 #include <stdio.h> 2 #include <string.h> 3 #include <unistd.h> 4 #include <signal.h> 5 int g_iSeq=0; 6 7 void SignHandlerNew (int iSignNo ,siginfo_t *pInfo,void *pReserved) 8 { 9 int iSeq=g_iSeq++;10 printf("%d enter Signhandlernow.signo:%d.\n",iSeq,iSignNo);11 sl 阅读全文
posted @ 2013-02-16 16:39 notepi 阅读(804) 评论(0) 推荐(0)
摘要:1 /* Copyright (C) 1991-2003, 2004 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Softw... 阅读全文
posted @ 2013-02-04 22:56 notepi 阅读(1412) 评论(0) 推荐(0)
摘要:如果用这个类型名来定义变量,可以这样写:struct complex_struct { double x, y;} z1, z2;这样z1和z2就是两个变量名,变量定义后面带个;号是我们早就习惯的。但即使像上面那样只定义了complex_struct这个Tag而不定义变量,后面的;号也不能少。这点一定要注意,结构体定义后面少;号是初学者很常犯的错误。不管是用上面两种形式的哪一种形式定义了complex_struct这个Tag,以后都可以直接用struct complex_struct来代替类型名了。例如可以这样定义另外两个复数变量:struct complex_struct z3... 阅读全文
posted @ 2013-01-29 14:32 notepi 阅读(274) 评论(0) 推荐(0)
摘要:头文件<setjmp.h>中的声明提供了一种不同于通常的函数调用和返回顺序的方式,特别是,它允许立即从一个深层嵌套的函数调用中返回。 int setjmp(jmp_buf env) setjmp 宏将状态信息保存到 env 中,供 longjmp 使用。如果直接调用 setjmp,则返回值为 0;如果是在longjmp 中调用 setjmp,则返回值为非 0。setjmp 只是用于某些上下文中,如用于 if 语句,switch 语句、循环语句的条件测试中及一些简单的关系表达式中。例如: if(setjmp(env) == 0) /* 直接调用 setjmp 时,转移到这里 */ e 阅读全文
posted @ 2013-01-25 02:12 notepi 阅读(326) 评论(0) 推荐(0)
摘要:#include <unistd.h>#include <stdio.h>#include <stdlib.h>int main(void){pid_t pid;if((pid=fork())==-1) { printf("error"); }else if(pid==0){printf("ok\n");exit(0);}else{printf("parent process,output begin\n");printf("hello word");_exit(0);}}调试后 阅读全文
posted @ 2013-01-24 04:03 notepi 阅读(7326) 评论(0) 推荐(0)