Another method to kick a user from a linux system?
Hi,
In a program I have, I need the ability to kick certain users from the server (running linux).
Currently, I am using a system call to pkill,
Code:
system("sudo pkill -KILL -u baduser > /dev/null 2>&1");
, but would like to get away from making system calls as they seem like lazy programming.
Is there an existing function, that can work in a similar way to pkill? I can't seem to find any with my searches. I'm looking into using kill(), but I need the programs pid. I think I need to kill the first pid listed to the user as that should be their shell process.
Any ideas?
Ty.