• Linux中关于进程方面常用函数的区别


     _exit和exit的区别
    _exit终止调用进程,但不关闭文件,不清除输出缓存,也不调用出口函数。exit函数将终止调用进程。在退出程序之前,所有文件关闭,缓冲输出内容将刷新定义,并调用所有已刷新的“出口函数”,最后调用_exit函数


    exec函数族  

      #include <unistd.h>
      int execl(const char *path, const char *arg, ...);
      int execlp(const char *file, const char *arg, ...);
      int execle(const char *path, const char *arg, ..., char *const envp[]);
      int execv(const char *path, char *const argv[]);
      int execvp(const char *file, char *const argv[]);
      int execve(const char *path, char *const argv[], char *const envp[]);

    执行exec容易发生问题,一定要加判断语句常见错误:找不到文件或者路径,errno=ENOENT数组argv和envp忘记用null技术,errno=EFAULT对执行文件没有权限,errno=EACCES

    子进程中执行exit(n)的时候,父进程可以用宏WEXITSTATUS(status)得到子进程n的值

    进程五种状态


    进程同步

    看的时候找一下waitpid和wait的区别

    原型:

    pid_t wait(int *status) 和 pid_t waitpid(pid_t pid, int * status, int options)

    sleep函数原型:

    unsigned int sleep(unsigned int seconds)

    改变进程优先权

    调用nice实现

    原型: int nice(int inc);

    Linux下进程通信的集中手段-六种

    1,管道及有名管道

    无名管道只能用于亲缘进程(父子进程或者兄弟进程),有名管道可用于非亲缘进程

    管道半双工,两个进程互相通信需要两个管道

    管道对于两个进程来说就是一个文件,单独构成文件系统,并且只存在内存中

    一个进程从管道这边写,另一个进程从管道那边读,只能写在管道的尾部,只能从管道头部开始读

    2,信号

    3,消息队列

    4,共享内存

    5,信号量

    6,套接字

    To be continue..

  • 相关阅读:
    multiprocessing模块
    socket&socketserver网络编程
    collections模块
    socket模块
    网络基础知识
    迭代器,生成器,列表推导式,生成器表达式
    logging模块
    Module
    页面中公用的全选按钮,单选按钮组件的编写
    ajax
  • 原文地址:https://www.cnblogs.com/zhongwh/p/2036790.html
Copyright © 2020-2023  润新知