Robin Dunn wrote:
Christian Kristukat wrote:
Hi,
there is some kind of conflict when trying to use grace_np (python wrapper for xmgrace) together with wxPython.
Which version of wxPython? What platform? Where can we find out more
wxPython 2.4.1.2 for python 2.3 on SuSE linux 9.0
about grace_np? How are you combining the two?
You can find a copy of grace_np.py on http://www.idyll.org/~n8gray/code/ (look for gracePlot.py). It basically starts xmgrace in a pipe and passes commands to it.
I quote the interesting parts - the error is reported at the signal call:
-----------------------------snip
# Python, by default, ignores SIGPIPE signals anyway
#signal.signal(signal.SIGPIPE, signal.SIG_IGN)
# Don't exit when our child "grace" exits (which it could if
# the user clicks on `exit'):
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
# Make the pipe that will be used for communication:
(fd_r, fd_w) = os.pipe()
cmd = cmd + ('-dpipe', `fd_r`)
# Fork the subprocess that will start grace:
self.pid = os.fork()
# If we are the child, replace ourselves with grace
if self.pid == 0:
try:
# This whole thing is within a try block to make sure
# the child can't escape.
for i in range(OPEN_MAX):
# close everything except stdin, stdout, stderr
# and the read part of the pipe
if i not in (fd_r,0,1,2):
try:
os.close(i)
except OSError:
pass
try:
os.execvp('xmgrace', cmd)
except:
# we have to be careful in the child process. We
# don't want to throw an exception because that would
# allow two threads to continue running.
sys.stderr.write('GraceProcess: Could not start xmgrace\n')
os._exit(1) # exit this forked process but not the parent
except:
sys.stderr.write('Unexpected exception in child!\n')
os._exit(2) # exit child but not parent
# We are the parent -> keep only the writeable side of the pipe
os.close(fd_r)
---------------------------snap
I already found at that when commenting out the signal call it works anyway but I'm not sure about the consequences.
Christian