GP2X Acid-2x New Gp2x Front-end


Azagaroth

Still Fresh
Joined
Nov 27, 2006
Messages
1
Hello guys,

I have been coding a neat little replacement front-end for the GP2X, and was looking for a bit of advice, particulary from Ryo (gmenu2x), as that is a very good project.

Basicly, I have already written all the GUI functionality, which is working really well. Taskbar, multiple desktops, containers, dialogs, menus, etc are all implimented.

But now im moving onto the actual core of the project, and unfortunatly its something I know very little about. Im currently trying to work on a function to run an external application on the GP2X, such as "mygame.gpe", then return control back to ACID-2X (my front-end).

I have some clever little data structures for storing 'link' information, but the actual process of executing the external application I am not having luck with. Here is the code I am using:

Code:
bool executeExternal(char *exec_path, char *cmd_line) {
   // function parameters
	pid_t pid;
	int rv;
	int commpipe[2];
   // setup communication pipeline
	if (pipe(commpipe)) {
	  return false;
	}
   // now attempt to unix FORK!
   pid = fork();
	if (pid == -1) {
	  return false;	
	}
   // if the process is ACID-2X
	if (pid){
		dup2(commpipe[1],1);
		close(commpipe[0]);
		setvbuf(stdout,(char*)NULL,_IONBF,0);
		wait(&rv);
   // if the process is child
	} else{
		dup2(commpipe[0],0);
		close(commpipe[1]);
		if (execl(exec_path, cmd_line, NULL) == -1){
		 return false;
		}
	}
	return true;
}

Any ideas? If someone can push me in the right direction I would appreciate that very much!...

Also, the standard GPH application. I notice since FW2.1 that only mplayer and MusicPlayer are still stand-alone programs... That kinda sucks, but part of ACID-2X will be developing a decent text reader etc... anyway.

What command lines does mplayer and MusicPlayer take?
 
What you ask for equals the basic commands; gosub and return to gosub only sub is here and external application.
I don't read that code to well and don't have the thingy/ programming enviroment yet myself so I guess if you know the code is right, the application you try to execute externally dosn't include a return from gosub equlant command in its loop, or (depending on how the GUI functonalities are set up ; (I read you've set it up and it works well), there might be some problem in your appl."code" somewhere), also be carefull using the wait command which I see is in there btw..

Ps I have no idea what I'm writing :p
 
Probably better to use waitpid than just wait.. if you use plain wait then check the return to make sure that the process that just signalled is the same one that you executed, otherwise your execute routine can potentially finish early.
 
Your method seems ok if you want the frontend to wait in the background while the launched app is running but maybe it would be better to just exit and rely on the autorun function to restart the frontend when the launche app terminates.
 
Back
Top