On Sat, 27 Jun 2015 10:12:01 +0200
Tobias Boege <tabo...@gmail.com> wrote:

> On Sat, 27 Jun 2015, adamn...@gmail.com 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 <adamn...@gnail.com (sort of)>

------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to