ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
But to stop the process i use process->kill() option, so maybe this is the reason. Nevertheless I couldn't find the exit codes for mplayer, anywhere.
But this is still ok, mplayer starts, until I exceed the given memory size. Then this fails to start, also udhcp fails to start. Any process.
Your hypothesis that sometimes you can't start 'mplayer' because of too many processes already running is a valid one.
As I've suggested, wrap 'mplayer' by a script and in that script invoke 'mplayer' this way:
Code:
mplayer <all_the_needed_args> 1>mplayer.log 2>&1
- I assume you do not need 'mplayer' stdout, so it can be redirected to a file - along with stderr. Then upon failure look into 'mplayer.log' file - maybe you'll see some useful messages.
Regarding processes - you can run 'ps' in a manner allowing to see process trees, so analyzing process tree you might come to a conclusion regarding the root cause of having too many processes.
Your hypothesis that sometimes you can't start 'mplayer' because of too many processes already running is a valid one.
As I've suggested, wrap 'mplayer' by a script and in that script invoke 'mplayer' this way:
Code:
mplayer <all_the_needed_args> 1>mplayer.log 2>&1
- I assume you do not need 'mplayer' stdout, so it can be redirected to a file - along with stderr. Then upon failure look into 'mplayer.log' file - maybe you'll see some useful messages.
Regarding processes - you can run 'ps' in a manner allowing to see process trees, so analyzing process tree you might come to a conclusion regarding the root cause of having too many processes.
Thank You for advices, the thing I do is a kind of an application that has a music (voice notes - recording (arecord) and playback(mplayer)). And since this is an ARM (so not that fast as pc), the mplayer starts a bit slower and I ned to know the exact time of starting the playback (actual sound comes out) - first libraries are loaded. It has a delay of 1-2seconds and this is out of question that I use QProcess started() signal. This signal is sent at the point, when loading libraries starts. So what I do, I read the output and when I get "Starting playback" string, I send a feedback to my GUI. With log file, I think it would be problematic - could use grep, or something like that, but still would have to use QProcess to get the feedback in appropriate time.
When it comes to multitude of processes - there are few, because the application is modular - loads created plug-ins. They are all graphical, so take some memory (png-s), but cannot be freed dynamically and then loaded, because it takes too much time for switching between them and the application wouldn't be "user friendly".
If only there was no restriction to the feedback signals the solution of Yours would be the best. However I even have udhcp process run and am reading stdout, to get if (and exactly when - to inform a user) the dynamic IP was assigned. So I need the QProcess... badly.
Therefore the only one solution I can come up with is to allow more for one process (at least it seems to me like this... the easiest solution). This is because when even qprocess fails, console applications may be still run - no problem. So I think, I need to set limits higher, however this is not thta easy, because there is nothing like limits.conf file. The process "ulimit" exists but it may be called only with value or "unlimited" tag (ulimit [limit], no options like ulimit [-acdfHlmnpsStuv] [limit]). And already is set to "unlimited". I just wrote on Angstrom specific mailing list.
Thank You for the time, I really appreciate Your efforts.
So far, I have to wait, helplessly.
Thank You for advices, the thing I do is a kind of an application that has a music (voice notes - recording (arecord) and playback(mplayer)). And since this is an ARM (so not that fast as pc), the mplayer starts a bit slower and I ned to know the exact time of starting the playback (actual sound comes out) - first libraries are loaded. It has a delay of 1-2seconds and this is out of question that I use QProcess started() signal. This signal is sent at the point, when loading libraries starts. So what I do, I read the output and when I get "Starting playback" string, I send a feedback to my GUI. With log file, I think it would be problematic - could use grep, or something like that, but still would have to use QProcess to get the feedback in appropriate time.
When it comes to multitude of processes - there are few, because the application is modular - loads created plug-ins. They are all graphical, so take some memory (png-s), but cannot be freed dynamically and then loaded, because it takes too much time for switching between them and the application wouldn't be "user friendly".
If only there was no restriction to the feedback signals the solution of Yours would be the best. However I even have udhcp process run and am reading stdout, to get if (and exactly when - to inform a user) the dynamic IP was assigned. So I need the QProcess... badly.
Therefore the only one solution I can come up with is to allow more for one process (at least it seems to me like this... the easiest solution). This is because when even qprocess fails, console applications may be still run - no problem. So I think, I need to set limits higher, however this is not thta easy, because there is nothing like limits.conf file. The process "ulimit" exists but it may be called only with value or "unlimited" tag (ulimit [limit], no options like ulimit [-acdfHlmnpsStuv] [limit]). And already is set to "unlimited". I just wrote on Angstrom specific mailing list.
Thank You for the time, I really appreciate Your efforts.
So far, I have to wait, helplessly.
The item in bold suggests poor architectural choice you've made.
The item in bold suggests poor architectural choice you've made.
Hello Mr. Sergei once more,
I try to get rid of the feedback, nevertheless even system() call doesn't work for me. The error I get is "Cannot allocate memory". As I mentioned before, while this happens, I can still run the same process from within the console, so this is not a limitation of the hardware.
I read that when this happens - its either memory limitation for process, or sometimes file descriptors limitation. Nevertheless I tried to change both with setrlimit() function with no avail (To check that setters worked correctly, after having set each parameter I checked if they were set using getrlimit() counterpart). It still errores me with "cannot allocate memory" error. Have You ever encountered such a thing? Do You, by any chance know how to overcome it?
I try to get rid of the feedback, nevertheless even system() call doesn't work for me. The error I get is "Cannot allocate memory". As I mentioned before, while this happens, I can still run the same process from within the console, so this is not a limitation of the hardware.
I read that when this happens - its either memory limitation for process, or sometimes file descriptors limitation. Nevertheless I tried to change both with setrlimit() function with no avail (To check that setters worked correctly, after having set each parameter I checked if they were set using getrlimit() counterpart). It still errores me with "cannot allocate memory" error. Have You ever encountered such a thing? Do You, by any chance know how to overcome it?
Any help is appreciated. Thank You.
AFAIK, nowadays 'mplayer' is based on 'ffmpeg', i.e. the codec functionality is inside 'ffmpeg'. So, maybe you'll use 'ffmpeg', which is also a library, instead of 'mplayer', so you won't need to have IPC (at least, with 'mplayer').
AFAIK, nowadays 'mplayer' is based on 'ffmpeg', i.e. the codec functionality is inside 'ffmpeg'. So, maybe you'll use 'ffmpeg', which is also a library, instead of 'mplayer', so you won't need to have IPC (at least, with 'mplayer').
But there is not ffmpeg installed on the device and I am not allowed to do it by myself. And, still I would have to call system("ffmpeg ..."), wouldn't I?
Thank You for sharing Your ideas, glad to read them.
But there is not ffmpeg installed on the device and I am not allowed to do it by myself. And, still I would have to call system("ffmpeg ..."), wouldn't I?
Thank You for sharing Your ideas, glad to read them.
No, you wouldn't - as I said, 'ffmpeg' is also a library. And that was the point.
Who doesn't allow you to install what you need to do your programming ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.