If I start a GNU screen session as a daemon, how would I retrieve its PID programmatically? I don’t know how consistent the output of screen -ls is, so I’d like to know how to do this with one of bash’s constants, $$, $! or a better alternative.
I am starting the screen with screen -dmS screenname.
How would I get the PID of a screen right before or immediately after starting the screen session?
This show the pid for a screen named
nameofscreen: