Let's say the user opens an "xclock &" in one of my scripts and I don't want him to be able to re-open one with the script. How could I test that? Possibly with a message saying that "The <xclock(or w/e other process like xcalc)> is already running in the background".
I checked the ps command but I can't figure out what I could do with it.
And then use the script I provided as kind of a generic launcher which will take program name as input. There are multiple ways of ensuring that only one instance runs for a user like checking ps or creating lockfiles etc.etc. Modify suitably to best suit your environment / requirements. I assume you will be able to figure that out by yourself.