Ok, I got it works. My code like this:
Code:
pid_t play_pid;
void window1::on_quit1_activate()
{
hide();
kill(play_pid, SIGTERM);
}
void window1::on_button1_clicked()
{
Glib::ustring file_p;
file_p = entry1->get_text();
play_pid = fork();
if(play_pid==0) {
char *argv[3] = { 0 };
argv[0] = "/usr/bin/mplayer";
int length = file_p.length();
argv[1] = new char[length+1];
file_p.copy(argv[1],length,0);
argv[1][length] = '\0';
execl( argv[0], "mplayer", argv[1], NULL );
}
else if(play_pid==1) {
}
}
Feel free to comment my code. So, I got one question. Not technical one. But this important ( for me, of course ). In opensource community, I found a lot of front end applications. Something like qtparted, synaptic, GPA ( gnupg frontends ), xcdroast. I just want to make one. Is this the way ( I mean the code ) how people make the front ends applications? Calling back ends applications by using fork(), execl(), execl(), execv() statements. Today, I googled about this ( signal stuff, fork() stuff, zombie process ) for hours. Looks these statement are not portable. Because almost in every tutorial I read, the authors mentioned about Unix. So I assumed I can not use this code under Windoze plafform. I mean maybe I can use fork() statement but I can not use signal stuff related code. Am I right? I hope I could make multi-platform front end applications. Thx.