g_spawn_async_with_pipes() vs system()

2008-10-25 Thread Dan Saul

Hi,

I am having some trouble getting g_spawn_async_with_pipes to function.

What I am trying to do is launch mplayer as a sub process to show a  
movie in one of my windows (-wid option).


Running system() works fine with the generated command line argument,  
but no such luck with g_spawn_async_with_pipes.


To generate the command line I use the following.

id MAString m_bin = @/usr/bin/mplayer;
int m_wid = (int)GDK_WINDOW_XID([b1 widget]-window);
id MAString m_media_file = [@Monster House.vob shellEscapedString];
id MAString m_args = [MAGString stringWithFormat:@%@ -wid %d - 
msglevel all=9 %@,m_bin,m_wid,m_media_file];


This gives us as an example

/usr/bin/mplayer -wid 35651615 -msglevel all=9 'Monster House.vob'

If we pass this to system it works fine.

system([m_args cString]);

However if we try to set this up with g_spawn_async_with_pipes it does  
not. I must be missing something obvious... The following does launch  
mplayer, however it states that file is not found. I have already  
tried putting extra quotes around Monster House.vob in the case that  
g_spawn_async_with_pipes strips them off before passing them to  
mplayer, no luck However.


int argc;
char ** argv;
GError * err = NULL;


gboolean success = g_shell_parse_argv([m_args cString], argc, argv,  
err);

assert(success == TRUE);



success = g_spawn_async_with_pipes(.,  argv, NULL, 0, NULL, NULL,  
childPid, in_fd, out_fd, NULL, err);

assert(success == TRUE);

Any thoughts would be appreciated (or if you know of a tutorial for  
this function),

Dan Saul
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_spawn_async_with_pipes() vs system()

2008-10-25 Thread Allin Cottrell
On Sat, 25 Oct 2008, Dan Saul wrote:

 What I am trying to do is launch mplayer as a sub process to 
 show a movie in one of my windows (-wid option).
 
 Running system() works fine with the generated command line 
 argument, but no such luck with g_spawn_async_with_pipes.
 
 To generate the command line I use ... [some weird stuff]

The following works (without the -wid bit, which I can't easily 
replicate, but which you could easily add).  Connect up the pipes, 
of course, if you want them.  name space.mpg is in the current 
directory when the program is invoked.

#include glib.h
#include stdio.h

int sample_spawn (void)
{
GError *error = NULL;
gchar *argv[6];
gint ok;

argv[0] = /usr/bin/mplayer;
argv[1] = /usr/bin/mplayer;
argv[2] = -msglevel;
argv[3] = all=9;
argv[4] = name space.mpg;
argv[5] = NULL;

ok = g_spawn_async_with_pipes (NULL,
   argv,
   NULL,
   0,
   NULL,
   NULL,
   NULL,
   NULL,
   NULL,
   NULL,
   error);

if (!ok) {
fprintf(stderr, error: '%s'\n, error-message);
g_error_free(error);
}

return !ok;
}

int main (void)
{
sample_spawn();
return 0;
}

Allin Cottrell


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list