Uptime under linux in C

后端 未结 3 1752
说谎
说谎 2021-02-20 05:41

How can I retrieve uptime under linux using C? (without using popen and/or /proc)

Thanks

3条回答
  •  星月不相逢
    2021-02-20 06:17

    To get the system start time in a more portable way, would be to use "who -b". To use this in a program you would have to spawn a shell and interpret its output. Unfortunately this seems the only place where such an information is available in POSIX, and this also only as an extension.

提交回复
热议问题