How to tell if running in a linux console versus an ssh session?
Posted
by Stéphane
on Stack Overflow
See other posts from Stack Overflow
or by Stéphane
Published on 2010-05-25T19:55:32Z
Indexed on
2010/05/25
20:11 UTC
Read the original article
Hit count: 206
I have an application that needs to behave differently if run directly from the linux console. So if a user connects with SSH to run FooBar, or the user walks over to the console and logs in directly to run FooBar, I want it to do something different.
What C API do I need to call to tell the difference between these two scenarios? I was thinking I'd have to look at the "tty/pts" information (such as what I see when I run "ps axf"), but I'm not certain if that is the best solution, nor what API to call to get that information.
Hints appreciated. :)
© Stack Overflow or respective owner