Hi, I have a python script that calls macros in OpenOffice.org like this: --------------------- ....
localContext = uno.getComponentContext() resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext) try: ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext") except: print "\nSome error message..." sys.exit(1) smgr = ctx.ServiceManager desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx) dispatcher = smgr.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx) dispatcher.executeDispatch(desktop, macro, "", 0, ()) ctx.ServiceManager --------------------- But, some times openoffice.org crashes and hangs. Then this python script hangs on "dispatcher.executeDispatch(desktop, macro, "", 0, ()) " So I tried to put an alarm around it like this: ---------------------- def handle_timeout(signum, frame): print 'Timeout!' sys.exit(1) old = signal.signal(signal.SIGALRM, handle_timeout) signal.alarm(1) try: dispatcher.executeDispatch(desktop, macro, "", 0, ()) finally: signal.alarm(0) signal.signal(signal.SIGALRM, old) ----------------------- >From strace, I can see that the alarm signal is sent, but it looks like the signal is masked, and the script does not print "Timeout!", and it does not exit. If OpenOffice.org is not alive, I want to kill OpenOffice and restart the scirpt. How can I check that OpenOffice.org is alive? I tried to check what OpenOffice.org was doing, but no luck: $ ps aux | grep -i soffice.bin knobo 2675 90.9 1.6 532580 32944 pts/0 Sl Aug06 4042:57 /usr/lib/openoffice/program/soffice.bin -accept=socket,host=0,port=2002;urp; -splash-pipe=5 $ strace -f -p 2675 attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted $ who am i knobo pts/2 2010-08-06 14:03 (:0.0) -- Knut Olav Bøhmer