I know there are two ways
- sysinfo function call
- /proc/uptime
I think sysinfo gets the uptime from the /proc/uptime. But the problem is if the user logouts and logs back in , the timer doesn't get reset. It keeps getting continued.
In windows, GetTickCount64() resets the timer on user logoff and logon. I want something similar in linux.
So how do i find the system elapsed time , since the last logon?
Thank You
edit: c++ code or api function call would be nicer, instead of spawning a process to call who or last command