Until now I used

```
pidof -o %PPID -x "my-tool"

```

To detect the pid of an eventually running instance of my-tool.

This is the short version of my-tool file, an executable bash script

```
#!/bin/bash 

if pidof -o %PPID -x "my-tool"; then
   echo "Already running"
   exit 1
fi

 ... if not running go on 

```

But now I need to allow *a single instance per user and multiple per machine*, so we can have even 100 my-tool running in the same moment, but only 1 per user.

Note that I need a test to create something like a singleton. If the tool will be started and there is another instance running it will close itself. 

**In short: I need that a bash script could detect if itself is already running for the current user and in this case it must exit.**

How to ?