自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 资源 (6)
  • 收藏
  • 关注

原创 exec 函数

fork/exec wait/exit 这两对函数构成了基本的进程控制函数。fork和exec的区别:fork时,父进程的文件描述符都被子进程继承。exec时,父进程的文件描述符由相应的FD_CLOEXEC决定。该flag由fcntl设置。如果设置了该flag,则文件将关闭,否则仍然保持打开。看一下下面的例子。 ======================================#include #include #include #include char *env_init[]

2010-07-30 11:44:00 649

原创 Race Condition between Father and Son

<br />子进程继承了父进程的很多资源,包括了文件描述符,<br />这样双方在执行时,就有可能产生竞争。<br /> <br />看下面的例子。 <br />#include <stdio.h><br />#include <unistd.h><br />#include <stdlib.h><br />#include <sys/wait.h><br /><br />static void charatatime(char *str)<br />{<br />    char 

2010-07-30 11:19:00 707

原创 防止僵尸进程的产生

APUE的代码直接贴这里。 #include "apue.h"#include intmain(void){ pid_t pid; if ((pid = fork()) err_sys("fork error"); } else if (pid == 0) { /* first child */ if ((pid = fork()) err_sys("fork error");

2010-07-29 17:42:00 788

原创 生成僵尸进程

定义:In UNIX System terminology, a process that has terminated,but whose parent has not yet waited for it, is called a zombie. 在UNIX 系统中,一个进程结束了,但是他的父进程没有等待(调用wait / waitpid)他, 那么他将变成一个僵尸进程. 但是如果该进程的父进程已经先结束了,那么该进程就不会变成僵尸进程, 因为每个进程结束的时候,系统都会扫描当前系统中所运行的

2010-07-29 10:28:00 877

原创 setuid,setgid的作用

<br />先来看下面的code<br />#include <stdio.h><br /><br />int main()<br />{<br />    printf("pid:  %d/n", getpid());<br />    printf("ppid: %d/n", getppid());<br />    printf("uid:  %d/n", getuid());<br />    printf("euid: %d/n", geteuid(

2010-07-27 21:45:00 1217

原创 单例模式C++表示

下面是个单例模式的例子。1. 类中有一个static的类指针2. 有一个static的类成员函数,返回该static指针。 static的成员函数只能访问static的成员变量。3. 该static指针的初始化,是单独列出来的,且在进入main函数前执行4. 还有一个奇怪的地方,Singleton的构造函数是private的,为什么可以new Singleton()?#include using namespace std;//Singleton C++class Singleton{p

2010-07-23 14:35:00 976

原创 C++拷贝构造函数及重写operator =的区别

先来代码:#include using namespace std;class CA{public:    CA(int b)    {        cout         a=b;    }    CA(const CA& C) // 拷贝构造函数    {        cout         a=C.a;    }    CA& operator=(const CA& C)//重写operator=    {        co

2010-07-23 10:26:00 5558

原创 multiple repeats

<br />其实就是对有相同pattern的行,做同样的动作。<br />:help :g<br />:help Ex<br /> <br />比如想要删掉以!开头的行<br />:g/^!/norm dd<br />就可以了。

2010-07-22 23:22:00 1806

原创 setjmp 和 longjmp,以及对变量的影响

<br />setjmp/longjmp是用来做non-local goto的。 一般情况下不建议使用。<br /> <br />先来看个例子。 <br />#include <sys/types.h>  /* for socket(2) and related bits and pieces */<br />#include <sys/socket.h> /* for socket(2) */<br />#include <net/if.h>     /* for struct ifreq */<

2010-07-22 10:50:00 1800

原创 vim中使用gdb, pyclewn

<br />http://easwy.com/blog/archives/advanced-vim-skills-vim-gdb-pyclewn/<br />:help pyclewn获得在线帮助<br /> <br />1. 安装<br />http://sourceforge.net/projects/pyclewn/ 下载<br />阅读INSTALL 查看安装方式。<br /> <br />2. 启动<br />#pyclewn<br />:e source_file<br />:Cfile E

2010-07-21 21:39:00 2340

原创 GDB中 打印出链表的值

这个东东怎么弄? 回去网上查查

2010-07-21 09:56:00 5323

转载 ioctl 开启/关闭网络接口

<br />int interface_up (char * interface_name)<br />{<br />    int s;<br />    if((s = socket(PF_INET,SOCK_STREAM,0)) < 0)<br />    {<br />        perror("Socket");<br />        return -1;<br />    }<br /><br />    struct ifreq ifr;<br />

2010-07-20 14:38:00 1779

原创 friend的定义 和 使用

<br />声明了友元函数或类后,该函数或类就可以访问相应类的private和protected成员了。<br />在下面的例子中,一个是定义了Internet类是Country类的友元类,这样Internet类中的成员函数就可以访问Country类的私有成员了。<br />另一个例子是定义了函数ShowN()是Internet类的友元函数,同理,ShowN()就可以访问Internet的私有成员了。<br /> <br />然后,一个函数可以是多个类的友元。下面例子中的ShowAll()函数,即是Inte

2010-07-17 11:30:00 1378

原创 类的封装,即public, private, protected关键字

三种关键字的使用

2010-07-16 15:26:00 2853

原创 函数重载(overload)、覆盖(override)、隐藏(hide)的区别

函数重载的定义

2010-07-16 15:26:00 1338

原创 虚函数

。。。

2010-07-16 15:25:00 675

原创 time时间相关的一些函数

<br />#include <utmp.h><br />#include <utmpx.h><br />#include <stdio.h><br />#include <time.h><br /><br /><br />int main()<br />{<br />    time_t t1;<br />    struct timeval t2;<br />    struct tm      *local_time, *utc_time;<br />    cha

2010-07-14 15:27:00 712

原创 getutent 读取utmp和wtmp,获得login account

这个是得到utmp的#include #include #include #include #include #include int main(int agrc, char* argv[]){    struct utmp* entry;    int i = 0;    setutent();    while ((entry = getutent()) != NULL)    {        i++;//        if(entry->ut

2010-07-14 14:22:00 2254

原创 gethostbyname

#include    #include    #include #include /*  * ===  FUNCTION  ====================================================================== *         Name:  main *  Description:   * ================================================================

2010-07-12 22:44:00 960

原创 用ioctl设置mac地址 得到当前的ip地址,子网掩码等信息

#include /* for socket(2) and related bits and pieces */ #include /* for socket(2) */ #include /* for struct ifreq */ #include /* for ARPHRD_ETHER */ #include /* for IOCTL's */ #include /* for fprintf etc */ #include /* f

2010-07-12 14:57:00 5407 2

原创 修改用户资料

man usermod <br />USERMOD(8) USERMOD(8)<br /><br />名称<br /> usermod - 修 改 使 用 者 帐 号<br /><br />语法<br /> usermod [-c comment] [-d home_dir [ -m]]<br /> [-e exp

2010-07-06 11:50:00 929

原创 使用standard IO(libc)复制文件

<br />int<br />main(void)<br />{<br />     int     c;  <br /><br />     while ((c = getc(stdin)) != EOF) <br />         if (putc(c, stdout) == EOF)<br />             err_sys("output error");<br />     <br />     if (ferror(stdin))<br />  

2010-07-05 10:07:00 794

原创 printf examples

<br />int main ( int argc, char *argv[] )<br />{<br />    printf("Characters: %c %c %c  /n", 'a', 65, 66);<br />    printf("Decimals: %d %+d %ld  /n",1977, 1977, 650000L);<br />    printf("Preceding with blanks: %10d /n", 1977);<br />    printf("

2010-07-04 11:05:00 745

intel ia32 programming guide

intel ia32 programming guide. for the reference for others.

2013-07-18

debug.hacks

debug.hacks 深入调试的技术和工具

2013-06-06

slide on dma

描述了硬件层面dma controller的位置。 以及dma与系统其他部件交互的详细过程。

2012-07-18

DOS6.0 image

This is the floppy boot disk of MSDOS6.0

2008-11-27

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除