zoukankan      html  css  js  c++  java
  • struct utmp

    utmp结构体定义如下:

    structutmp
    {
      short int ut_type; // 登录类型
      pid_t ut_pid; // login进程的pid
      char ut_line[UT_LINE_SIZE]; // 登录装置名,省略了"/dev/"
      char ut_id[4]; // Inittab ID
      char ut_user[UT_NAMESIZE]; // 登录账号
      char ut_host[UT_HOSTSIZE]; // 登录账号的远程主机名称
      struct exit_status ut_exit; // 当类型为DEAD_PROCESS时进程的结束状态
      long int ut_session; // SessionID
      struct timeval ut_tv; // 时间记录
      int32_t ut_addr_v6[4]; // 远程主机的网络地址
      char __unused[20]; // 保留未使用
    };

    ut_type有以下几种类型:

    exit_status结构体定义:

    structexit_status
    {
        short int e_termination; //进程结束状态
        short int e_exit; //进程退出状态
    };

    getutnet()函数 

    头文件:

    #include<utmp.h>

    定义函数:

    struct utmp *getutent(void);

    函数说明:

    getutent()用来从utmp文件(/var/run/utmp)中读取一项登录数据,该数据以utmp结构返回。第一次调用时会取得第一位用户数据,之后没调用一次就会返回下一项数据。直到已无任何数据时返回NULL。

    setuent()函数

    头文件:

    #include<utmp.h>

    函数定义:

    void setutent(void);

    函数说明:

    setuent()用来将getuent()读写地址指回utmp文件开头。

    endutent()函数:

    头文件:

    #include<utmp.h>

    函数定义:

    void endutent(void);

    函数说明:

    endutent ()用来关闭getuent所打开utmp文件。

  • 相关阅读:
    python不同包之间调用时提示文件模块不存在的问题
    adb shell 查看内存信息
    adb shell top 使用
    Android读取logcat信息
    父类的引用对象指向子类的对象
    我的阿里梦——淘宝前端必备技能
    我也做了一个1/4圆形菜单
    可编辑tab选项卡
    canvas 之
    canvas之----浮动小球
  • 原文地址:https://www.cnblogs.com/wanghao-boke/p/11933300.html
Copyright © 2011-2022 走看看