Results 1 to 1 of 1
Hello all, some newbie linux help:
I am writing a c code using pocketsphinx: (a speech recognition engine in linux) which executes an application in linux (e.g firefox) on receiving ...
- 03-10-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 1
System call from pocketsphinx c code to exec an application in separate terminal
Hello all, some newbie linux help:
I am writing a c code using pocketsphinx: (a speech recognition engine in linux) which executes an application in linux (e.g firefox) on receiving a spoken command (e.g "open browser"). So far the code starts up the browser on recognizing the string but when the browser starts, pocketsphinx loses control of the terminal as control is passed to the child process namely exec (firefox). (I am using a fork and execl after fiddling around with system() with no luck). What I would like it to do is to start up the application and return control to the terminal; not to the home folder i.e user-laptop:~$ which it always seems to do when I add the '&' argument... so yes I have tried that, but to the pocketsphinx "ready" prompt running in the terminal waiting for voice input.
Here is an excerpt of the code as it stands now: This part contains the variable 'hyp' which receives the recognized string "OPEN BROWSER" and forks to open up the application Firefox:
if (hyp) {
sscanf(hyp, "%s", word);
if (strcmp(word, "OPEN BROWSER") == 0)
{if (fork()==0);{execl("/usr/bin/firefox", "firefox &"," ",(char *)0);}
}
}
So there it is. I'm not sure if doing this would require creating a daemon or the use of threads but I am surprised there is no functionality in linux to just start an application outside of the terminal (from within c). This has me presently stumped and although I have looked and tried various methods (popen, execv, exec), the result remains one of two: either I close the application and return control to the prompt, or the application executes and exits altogether.
Any suggestions?


Reply With Quote