[Fwd: Re: where is error? (Glib::spawn_async)]
- From: Michael J M Thomson <mjmt internode on net>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: [Fwd: Re: where is error? (Glib::spawn_async)]
- Date: Fri, 03 Nov 2006 14:17:55 +1100
-------- Original Message --------
Subject: Re: where is error? (Glib::spawn_async)
Date: Fri, 03 Nov 2006 14:11:46 +1100
From: Michael J M Thomson <mjmt internode on net>
To: Jonathon Jongsma <jonathon jongsma gmail com>
References: <200611030106 36174 pogonyshev gmx net>
<454A987E 8010507 internode on net>
<ee2fcb570611021750n5aa14e57ga86eda709905e7d9 mail gmail com>
Jonathon Jongsma wrote:
On 11/2/06, Michael J M Thomson <mjmt internode on net> wrote:
Paul Pogonyshev wrote:
> Hi.
>
> Where is error in this code fragment?
>
> std::vector <std::string> yelp_arguments;
>
> yelp_arguments.push_back ("yelp");
> yelp_arguments.push_back
("ghelp:///usr/share/gnome/help/gedit/C/gedit.xml");
>
> try
> {
> Glib::spawn_async (".", yelp_arguments, std::vector
<std::string> (),
> Glib::SPAWN_SEARCH_PATH);
> return;
> }
> catch (Glib::Error& exception)
> {
> g_print ("%s...\n", exception.what ().c_str ());
> }
>
> I get this in terminal:
>
> (yelp:14036): Gtk-WARNING **: cannot open display:
>
> and Yelp window is never shown.
>
> Paul
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
The third argument you're passing to Glib::spawn_async(),
std::vector<std::string>(), you shouldn't (and don't need to). It
becomes the
set of environment variables seen by the spawned child, instead of
those already
present in the parent process' environment. And while it may seem more
secure or
neater or something to change it, some variables are vital, e.g.
without DISPLAY
most Xlib-based programs won't work, and in GNOME's (and probably
KDE's and
other desktops) case there are several variables that allow session
management
and other desktop stuff to work properly. Non-GUI programs might also
crap out,
if they rely on e.g. HOME or USER (even though they shouldn't). Not
sure but Mac
OS X and probably Windows mightn't appreciate certain environment
variables not
being set properly ,either.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
what makes you say that you don't need to pass the third parameter?
the function expects a reference to an array here so you must pass it
something. Am I missing something?
No I probably wasn't clear, sorry. Just there are several overloads of
Glib::spawn_async(), one of which doesn't expect that argument:
Glib::spawn_async(const std::string& working_directory,
const Glib::ArrayHandle<std::string>& argv,
SpawnFlags flags = SpawnFlags(0),
const sigc::slot<void>& child_setup = sigc::slot<void>(),
Pid* child_pid = 0);
Kind of makes sense IMHO, if you consider vector<string>() as equivalent to
passing an empty array (char* env[1] = { NULL }) rather than NULL.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]