[Gambas-user] How to tell what invoked this program?

adamnt42 at ...626... adamnt42 at ...626...
Sat Jun 27 10:22:16 CEST 2015


On Sat, 27 Jun 2015 10:12:01 +0200
Tobias Boege <taboege at ...626...> wrote:

> On Sat, 27 Jun 2015, adamnt42 at ...626... wrote:
> > This is driving me insane!
> > 
> > How can I tell at runtime if the executable was invoked manually by a user or automatically by a scheduler, e.g. cron, anacron, at etc.
> > 
> > Can't use the process userid as it may have been invoked as a user cron job.
> > I am sure I have done this at least a gazillion times before.... but today????
> > 
> 
> *Maybe* examine the parent PID and look behind the symlink /proc/<ppid>/exe?
> I didn't test it though and I don't know how many names there are for
> (ana)cron, at, etc. on different distributions. Another idea would be, if
> that's possible, to introduce a command line option to your program and
> require the user to set it iff the program is started by such a daemon.
> 
> Regards,
> Tobi
> 
> -- 
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> 
Thanks Tobi,
I had been going down the task parent PID route (as I thought there was a "simple" answer that way) but I fear you may be correct - setting a "-d" option may ultimately be the easiest way to go.

... 

Grrr :-(

Some days are better than others.

b

-- 
B Bruen <adamnt42 at ...3379... (sort of)>




More information about the User mailing list