[Glade-users] Getting the menu toolbar items to execute other
executables ...
John Coppens
john@jcoppens.com
Thu, 28 Apr 2005 21:54:26 -0300
On Thu, 28 Apr 2005 14:59:12 -0700 (PDT)
bob smythe <sp4mhatah@yahoo.com> wrote:
> I'm just not quite sure what to try ... I've tried
> fork, execl, and system functions in the callback, but
> I'm not programming it right. The best I've been able
> to come up with is a method with execl that closes the
> menu and opens the ssh session in the same terminal
> window that started the menu.
I'm not too good a programmer either but I did some playing with those
functions. The exec-family of functions replaces the current process
(your selector program) with the new process (the program you're
starting). So you cannot get back afterwards.
System executes the command you want, but waits for it to stop before
continuing with the original program, which might be acceptable, but the
screen won't update anymore. Still, you might get away by simply adding
'&' at the end of the command line, causing the program to execute in
parallel.
If you want to keep the original process, you have to start a separate
process using fork(). Here's a very simple example of the use of fork:
http://www.amparo.net/ce155/fork-ex.html
But, if you're working with Gnome/Gtk, you're probably better of checking
the specialized function in the Glib library to hide some of the dirty
working in higher-level functions like g_spawn_async.
John