Re: 2 questions regarding a perl daemon with a GTK interface
- From: Etienne Grossmann <etienne anonimo isr ist utl pt>
- To: gtk-perl-list gnome org
- Cc: etienne isr ist utl pt
- Subject: Re: 2 questions regarding a perl daemon with a GTK interface
- Date: Fri, 11 May 2001 22:54:59 +0100
Hi Greg,
in fact, after answering your mail, I realized that I had never used
successfully the 'input_add' way of communicating between processes.
What I did succeed in doing is spawning a child and pass data to it
through a temporary file; the child is told to read the temp file when
it receives a USR1 or USR2 signal (set the corresponding signal
handler). I guess data could be sent back in the same way, through
another temp file.
Cheers,
Etienne
From: gfricke hushmail com
# Thank you to all those who responded to my initial post. I have since successfully
# implemented the "delete_event" signal to spawn my exit dialog window, so
# problem 2 is solved :) However, I'm note sure the solutions given for my
# first problem work in my case (I could be wrong, it may be exactly what
# I need but I have goten it to work yet). What I need is the ability to
# start and stop the daemon dependant on what buttons are clicked. I have
# tried to implement this by way of a variable "$daemonStarted" equal to 1
# for true and 0 for false. I used the fork command and wrote a condition
# that basically says, if $daemonStarted then listen for request else do nothing.
# Unfortunately, I discovered that when I click the start daemon button,
# the gui child process changes the value of its copy of $daemonStarted but
# the parent process' variable remained unchanged. I guess what I really
# need is a way to have the child process and the parent process access/modify
# the same variables, or for Gtk to somehow sit in the background, avoid the
# use of fork and allow a daemon loop to execute at the same time. Any suggestions/links/examp
# les
# would be greatly appreciated. Thanks in advance.
# Greg
# At Thu, 10 May 2001 09:02:07 +0100, Etienne Grossmann <etienne anonimo isr ist utl pt>
# wrote:
# >
# >
# > Hi,
# >
# >From: gfricke hushmail com
# ># All,
# ># I recently used glade to build my first perl program with a GUI
# ># interface. I have come across two problems that I haven't been
# ># able to figure out. My GTK experience is very minimal and my perl
# ># expertise is limited to just a few programs.
# >
# ># Problem 1 - How do I send GTK to the background so that I can run
# >a
# ># daemon loop listening for remote connections, yet having the GTK
# ># portion of the program still sending all the actions/signals to
# ># thier appropriate functions/handlers? If i enter my daemon loop
# ># after the Gtk->mainl command the loop never executes. Likewise if
# ># I insert the daemon loop before the Gtk->main call the window never
# ># appears.
# >
# > Maybe that's what you are looking for, taken from the perl-gtk
# >tutorial (http://personal.riverusers.com/~swilhelm/gtkperl-tutorial):
# >======================================================================
# >Monitoring IO
# >
# >A nifty feature of GDK (the library that underlies GTK), is the
# >ability to have it check for data on a file descriptor for you (as
# >returned by open() or socket()). This is especially useful for
# >networking applications. The function:
# >
# >$id = Gtk::Gdk->input_add( $source, $condition, \&function, @data );
# >
# >takes a file descripter you want watched as the first argument, and
# >the second argument specifies what you want GDK to look for. This may
# >be one of:
# >
# >'read' - Call your function when there is data ready for reading on
# > your file descriptor.
# >
# >'write' - Call your function when the file descriptor is ready for
# > writing
# >======================================================================
# >
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]