-
Recent Posts
Recent Comments
ali on Oprofile 0.9.6 ——-… Ola on Oprofile 0.9.6 ——-… tran dung on Oprofile 0.9.6 ——-… Jisu on Oprofile 0.9.6 ——-… Sachin Agarwalla on Oprofile 0.9.6 ——-… Archives
- December 2015
- August 2015
- June 2015
- May 2015
- January 2015
- October 2014
- September 2014
- June 2014
- May 2014
- March 2014
- February 2014
- January 2014
- November 2013
- October 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- January 2013
- November 2012
- September 2012
- August 2012
- July 2012
- June 2012
- April 2012
- March 2012
- February 2012
- January 2012
- November 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
Categories
Meta
Category Archives: Linux
Linux shared memory & semaphore
Show all info: ipcs delete specific item: ipcrm [-m|-s]
Posted in Linux
Leave a comment
Linux daemon program
#include <unistd.h> #include <signal.h> #include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> void init_daemon(void) { int pid; int i; if(pid=fork()) exit(0);//是父进程,结束父进程 else if(pid< 0) exit(1);//fork失败,退出 //是第一子进程,后台继续执行 setsid();//第一子进程成为新的会话组长和进程组长 //并与控制终端分离 if(pid=fork()) exit(0);//是第一子进程,结束第一子进程 else if(pid< 0) exit(1);//fork失败,退出 //是第二子进程,继续 //第二子进程不再是会话组长 for(i=0;i< NOFILE;++i)//关闭打开的文件描述符 close(i); chdir(“/tmp”);//改变工作目录到/tmp umask(0);//重设文件创建掩模 return; … Continue reading
Posted in Linux
Leave a comment
Linux 线程
1. 在Linux上获得线程id #define gettid() syscall(__NR_gettid) 用到的地方 gettid() 2. 查找进程ID ps -ef | grep 进程name 3. 显示特定进程的线程 ls /proc/进程ID/task 4. 当用pthread_creat创建线程时, 当线程函数执行完,线程会自行消亡 (Uncertain) 5. 编译 多线程 程序 gcc -g -o test test.c -lpthread test 是文件名
Posted in Linux
Leave a comment