[gtkmm] Spawing a process and being notified of its termination
- From: "Pierre Bacquet" <Pierre Bacquet anite com>
- To: <gtkmm-list gnome org>
- Subject: [gtkmm] Spawing a process and being notified of its termination
- Date: Thu, 19 Feb 2004 14:33:45 +0100
Hi,
I am trying to understand of to fork/exec a process
and being notified of its termination by a call-back (CB)
mechanism.
Since my future software is supposed to run on several
platforms including Windows, I've started making a small
example on the platform I'm less confident on, i.e. Windows.
Here is part of my sample code :
---------------------------------------------------------------------------
void mainWin::on_runIt_pressed()
{
string wDir(".");
int pid;
vector<string> argv;
string cmd("C:\\Win2000\\regedit.exe");
Glib::SpawnFlags flags;
argv.push_back(cmd);
try
{
Glib::spawn_async(wDir, argv, flags, SigC::slot(*this, &mainWin::on_child_termination), &pid);
}
catch (Glib::Exception &e)
{
msgField->set_text(e.what());
}
}
void mainWin::on_child_termination()
{
msgField->set_text("Finito !!");
}
---------------------------------------------------------------------------
on_runIt_pressed() is triggered when I clik on a button surprisingly
named "Run It".
I expect here that the on_child_termination() CB is called when the
spawned child terminates, but I get the "Finito !!" message as soon as
the Regedit process is launched and not when I terminate it (closing its
window).
I must admint that the documentation on Glib::spawn_xxxx is quite light
and I would like to know how I can be notified of the death of the child
process.
TIA,
Pierre.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]