I'd like to create a secondary terminal (which will be the active one later) using fork and then execl (or execv). I managed to do it up to a point but I'm having trouble adding a timeout period.
Currently the code looks like this:
execl("/bin/timeout", "timeout", "1m", "/bin/bash", NULL);
I managed to be able to open a terminal using the above command but it won't timeout after 1 minute. This is going to be a child process, the parent process is the session manager.
I'd like the terminal to close connection after the user is being inactive for several minutes (1 minute in the above case). If the user starts giving out commands, the timer should restart. Is my approach ok for this? Why's the terminal not closing after 1 minute?
Thank you for your answers!
I managed to make it work according to John Bollinger's answer. Set the TMOUT env variable as readonly, it's fine for us even with not being "100% secure". Thanks everyone for answering!