g_spawn_async_with_pipes() vs system()



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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]