Welcome to the Linux Foundation Forum!

How to check whether 2 processes are running in the same logged in session?

Options

How to check whether ‘2 processes are running in the same logged in session’, considering the fact that same user COULD be logged in more than one session’ – and we are wanting to know ‘programatically’ if two processes are in the ‘same session or different sessions’?

**getsid(pid) ** returns the session id but if the same user is logged in from two different terminals using ssh on a Linux system, both the terminals will show different session for the same user.

So basically, I wanted to restrict the user from opening two instances of my application at the same time. I was using session id for this. But when the user is logged in from two different terminals the session id was not same in both terminals for the user (but in Windows it gave the same session id). Therefore, any idea how can I achieve the same in Linux?

Categories

Upcoming Training