[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Matt Gushee <matt@g...> |
| Subject: | Re: [Caml-list] LablGTK2: problem w/ GMain.Io |
Olivier Andrieu wrote:
>> and daemon modes with no apparent problems. On the second box, normal
>> mode works fine; the app will also run in daemon mode. But when I
>> attempt to send a command to the app in daemon mode, I get the following
>> error message:
>>
>> ** (bantam.bin:13244): CRITICAL **: GIOChannel watch: callback
raised \
>> an exception
>
> That's because your callback raised an exception (!). LablGTK traps
> uncaught exceptions from callbacks instead of re-raising them and exiting
> the main loop. For signals, there is a user-overridable handler that
> simply prints the exception name to stderr ; for other types of callbacks
> (IO watches, timeouts, etc.) you simply get this error message.
>
> In your code you should wrap your "watcher" function in a try...with
block
> and print the exception using Printexc.to_string to see what's going
> wrong.
Thanks for the tip ... I suppose I should have thought of it myself.
Anyway, I seem to have solved the problem ... I had:
msg_fd <-
Unix.openfile msg_pipe [Unix.O_RDONLY; Unix.O_NONBLOCK] 0o600;
Apparently the file descriptor should *not* be opened in non-blocking
mode (is that really so obvious that it doesn't need to be documented
anywhere??). But I'm still puzzled, because the behavior was very
inconsistent: it worked on one box but not another--though perhaps the
difference in GTK versions would account for that. What was really
strange, though, was that if I attempted to display the GUI in the
normal way, i.e. with the command
$ bantam -s
'bantam' being a shell script which, given the '-s' option, does the
following:
echo '%show' > ${TMPDIR}/bantam-${USER}/message.pipe
(which in my case resolves to
echo '%show' > /tmp/bantam-matt/message.pipe
) --this caused the I/O error. Yet, if invoked the same 'echo' command
directly in an interactive shell (in this case, bash running in an
rxvt), it never caused the error. Why on earth would that be, I wonder?
--
Matt Gushee
The Reluctant Geek: http://matt.gushee.net/rg/