Cron service spawns windowless child, how to create a window?

Reini Urban rurban@x-ray.at
Mon Jan 10 07:50:00 GMT 2011


2011/1/9 Błażej :
> Let me first explain the setup a little. I have a Windows PE app
> (written in Delphi) that I want to keep running at all times and also
> bullet-proof it against http connection timeouts, file reading errors
> etc. It logs its actions periodically to a logfile so based on whether
> this file was recently changed I can tell if the app is operational (ie.
> it could be up and running, but not doing its job as intended).
>
> Next up, I have cron running as service, I set up a following cronjob:
>  * * * * * ~/md5compare.sh

You are running into a limiation of the System user, even with desktop
interaction enabled not all GUI controls will work due to windows security,
and it's no good idea to use GUI's as service anyway.
Same nightmare as running a X server as root.

I would propose
1. to use the standard windows mechanisms instead. at /interactive ...
or 2. if it's possible for you, run cron as user, not as System.

Application wise people are usually just stat the size of a growing logfile,
not md5, and act accordingly.
Testing http timeouts or locks, I usually test with a periodic
httpping, not with a logfile.
If the ping to a reliable server fails something is going on. (Modem,
router, windows, ...)

> This script creates a MD5 checksum of the logfile and compares it with
> the one it created before. Source is here:
> http://www.linuxforums.org/forum/programming-scripting/1319-shell-script-commands-check-if-file-has-changed.html
> The important part that I changed is this:
>  if [ "$OLDMD5PRINT" = "$MD5PRINT" ]
>  then
>  pkill -9 appname
>  ~/linktoexe &
>  fi
> ("linktoexe" is a symbolic link to the .exe file located elsewhere in
> the Windows filesystem.)
>
> This setup works fine as far as its desired functionality goes ie. once
> the app is closed, abnormally stops its usual work, hangs on http
> request (etc), it takes at most 2 minutes to restart and restore its
> operation.
>
> However, there is a problem: the Windows application is started by the
> sh interpreter (which was run by the cron service), but in a windowless
> state. I figured this was a cron service problem so I allowed for it to
> communicate with the desktop (which is less than optimal) but that did
> not help - instead, the GUI is broken. It seems no controls originating
> from the app can be drawn in the window frame or tray icon (same with
> context menus). The app responds to all user input, as I can see in the
> logfile but doesn't give any visual feedback.
>
> I tried hard to find an answer to this problem but I'm not really
> Linux-savvy and my usual Google skills seem to have failed me.
> Therefore my question is, is it possible and if so, how, to have the
> Windows PE app run as intended, in a desktop window with its GUI fully
> functional?
>
> Thanks,
> Blazej
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>



-- 
Reini Urban
http://phpwiki.org/           http://murbreak.at/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list