LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-21-2010, 04:23 PM   #1
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Rep: Reputation: 15
QProcess, FailedToStart only on embedded linux


Hi everyone,

I have this problem and can't overcome it. Maybe someone of You has an idea. I would really appreciate it. So goint to the problem...

In my application I need to start mplayer with radiostation url. And it works for few first times. After I play with some gui in the application and want to start the process again, I get FailedToStart error and nothing happens. The arguments are the same, and the program "mplayer" still exists.
In the documentation, they write:
"The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program."
However this is obvious, none of the cases apply to mine. But it still fails.
Additionally, this happens when the program is run on Embedded Linux (on ARM). Running on Ubuntu, haven't gotten this kind of problem. So maybe it has something to do with resources, but how can I check it? How can I affect it, to correct? Please, I need this badly!

Thank You in advance, for any help.
 
Old 04-21-2010, 05:21 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Krzysztow View Post
Hi everyone,

I have this problem and can't overcome it. Maybe someone of You has an idea. I would really appreciate it. So goint to the problem...

In my application I need to start mplayer with radiostation url. And it works for few first times. After I play with some gui in the application and want to start the process again, I get FailedToStart error and nothing happens. The arguments are the same, and the program "mplayer" still exists.
In the documentation, they write:
"The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program."
However this is obvious, none of the cases apply to mine. But it still fails.
Additionally, this happens when the program is run on Embedded Linux (on ARM). Running on Ubuntu, haven't gotten this kind of problem. So maybe it has something to do with resources, but how can I check it? How can I affect it, to correct? Please, I need this badly!

Thank You in advance, for any help.
Do you have source code of the application which starts 'mplayer' ?
 
Old 04-21-2010, 05:36 PM   #3
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Sergei Steshenko View Post
Do you have source code of the application which starts 'mplayer' ?
Hi, thank You for being interester, this is my code (a bit altered)

Code:
bool MediaClass play(QString &sourceUrl)
{
 Process *process=new Process(this);
    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleErrors(QProcess::ProcessError)));
    connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()));
    QString processName("mplayer");
    QStringList parameters;

    //system("killall mplayer");//I also checked with this 

    parameters << sourceUrl;//here is http://gr-relay-3.gaduradio.pl/9 address
    parameters.append("-ss");
    parameters.append(QString::number(position));
    process->start(processName, parameters);
    connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));

    if (process->waitForStarted(1000))
    {
        qDebug()<<"AlsaAudioFunctions::play() : process has really started";
        _activeProcesses.insert(hardware, process);
        process->setProperty("type","play");
        process->setProperty("paused", false);
        process->setProperty("timestamp", QTime::currentTime());
        connect(process, SIGNAL(finished(int)), this, SLOT(processTerminated()));
        return true;
    }
    else
    {
        process->terminate();

    }
    return false;
}
Hope this helps anyhow.

I have additional question. May it happens due to resources limitation? How can I set, that one process is not limited, anyhow?

Thank You,
regards.
 
Old 04-21-2010, 05:45 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Krzysztow View Post
Hi, thank You for being interester, this is my code (a bit altered)

Code:
bool MediaClass play(QString &sourceUrl)
{
 Process *process=new Process(this);
    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleErrors(QProcess::ProcessError)));
    connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()));
    QString processName("mplayer");
    QStringList parameters;

    //system("killall mplayer");//I also checked with this 

    parameters << sourceUrl;//here is http://gr-relay-3.gaduradio.pl/9 address
    parameters.append("-ss");
    parameters.append(QString::number(position));
    process->start(processName, parameters);
    connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));

    if (process->waitForStarted(1000))
    {
        qDebug()<<"AlsaAudioFunctions::play() : process has really started";
        _activeProcesses.insert(hardware, process);
        process->setProperty("type","play");
        process->setProperty("paused", false);
        process->setProperty("timestamp", QTime::currentTime());
        connect(process, SIGNAL(finished(int)), this, SLOT(processTerminated()));
        return true;
    }
    else
    {
        process->terminate();

    }
    return false;
}
Hope this helps anyhow.

I have additional question. May it happens due to resources limitation? How can I set, that one process is not limited, anyhow?

Thank You,
regards.
So, Which of the two:

Code:
    process->start(processName, parameters);
    connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
fails ? Or the failure is somewhere else ?
 
Old 04-21-2010, 05:53 PM   #5
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Sergei Steshenko View Post
So, Which of the two:

Code:
    process->start(processName, parameters);
    connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
fails ? Or the failure is somewhere else ?
Ahh sorry, I haven't included the part of code taking care of errors. So here it comes:

Code:
void MediaClass::handleErrors(QProcess::ProcessError error)
{
    switch(error)
    {
    case (Process::FailedToStart):
        qDebug()<<"AlsaAudioFunctions::handleErrors() : Process::FailedToStart";
        break;
    case (Process::Crashed):
        qDebug()<<"AlsaAudioFunctions::handleErrors() : Process::Crashed";
        break;
    case (Process::WriteError):
        qDebug()<<"AlsaAudioFunctions::handleErrors() : Process::WriteError";
        break;
    case (Process::Timedout):
        qDebug()<<"AlsaAudioFunctions::handleErrors() : Process::Timedout";
        break;
    case (Process::ReadError):
        qDebug()<<"AlsaAudioFunctions::handleErrors() : Process::Crashed";
        break;
    default:
        qDebug()<<"AlsaAudioFunctions::handleErrors() :unknown error";
        break;
    }

    Process *process=dynamic_cast<Process*>(sender());
    if (process)
    {
        qDebug()<<"AlsaAudioFunctions::handleErrors() : "<<"Process22";
        process->close();

        if(process)
        {
            qDebug()<<"AAF : delte";
            process->deleteLater();
        }
    }
    else
        qDebug()<<"AlsaAudioFunctions::handleErrors() : "<<"Not recognized as QProcess";
}
So at this point I get sometimes an error saying: "AlsaAudioFunctions::handleErrors() : Process::FailedToStart".

The Process class is derived from Process. Only destructor and constructor functions are defined there, to indicate me if all the instances were deleted after creation.

Thank You.

Last edited by Krzysztow; 04-21-2010 at 05:54 PM. Reason: a mistake done
 
Old 04-21-2010, 06:12 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Krzysztow View Post
...
So at this point I get sometimes an error saying: "AlsaAudioFunctions::handleErrors() : Process::FailedToStart".

The Process class is derived from Process. Only destructor and constructor functions are defined there, to indicate me if all the instances were deleted after creation.

Thank You.
So, the error is obviously ALSA related - assuming the diagnostics are correct. You'll have to dig into 'mplayer' + ALSA.

My wild guess is that either another instance of 'mplayer' exists grabbing ALSA or when killing 'mplayer' (do you do this ?) previous instance you do not wait long enough.

Generally speaking, sending KILL to a process does not necessarily kill it immediately.

I'd suggest to temporarily wrap 'mplayer' into a script and call the script rather than 'mplayer' directly. In the script you can put various diagnostics before actually calling 'mplayer' - for example, 'ps auwx | grep mplayer' or something like this ('pgrep' ?) in order to check whether previous 'mplayer' instance still exists. And/or to check ALSA status. Things like that.
 
Old 04-21-2010, 06:22 PM   #7
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Sergei Steshenko View Post
So, the error is obviously ALSA related - assuming the diagnostics are correct. You'll have to dig into 'mplayer' + ALSA.

My wild guess is that either another instance of 'mplayer' exists grabbing ALSA or when killing 'mplayer' (do you do this ?) previous instance you do not wait long enough.

Generally speaking, sending KILL to a process does not necessarily kill it immediately.

I'd suggest to temporarily wrap 'mplayer' into a script and call the script rather than 'mplayer' directly. In the script you can put various diagnostics before actually calling 'mplayer' - for example, 'ps auwx | grep mplayer' or something like this ('pgrep' ?) in order to check whether previous 'mplayer' instance still exists. And/or to check ALSA status. Things like that.
This "AlsaAudioFunctions::handleErrors() : Process::FailedToStart" message is just my message from handleErrors() function (I left this name, since earlier I called it like that). It shouldn't be a problem of mplayer or alsa. I checked from console if I can start more than one mplayers with the links like that and it is possible, all is fine. Only from within qt application it fails. And when it does fail, I can check the list of running processes by ps -A and there is no other mplayer left. So probably it's not the case.
 
Old 04-22-2010, 02:41 AM   #8
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
Hi,

surely the problem is not Alsa specific, because when this mplayer fails, also QProcess with udhcp fails.

Before this failures happen, udhcp process works perfectly fine.

Thank You for any ideas!
 
Old 04-22-2010, 04:43 AM   #9
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Krzysztow View Post
Hi,

surely the problem is not Alsa specific, because when this mplayer fails, also QProcess with udhcp fails.

Before this failures happen, udhcp process works perfectly fine.

Thank You for any ideas!
Me once more...

So I run my application and on the second consloe observe the "top" output. And this QProcess::FailedToStart comes out, when the VSZ (Virrtual Memory Size) approaches 270m. But from the console mplayer may be played, so this is not a physical limitation of the hardware, but probably some limitation to a process.

So this is the state (top process run) when mplayer is running correctly:

Code:
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
 2289  2229 root     R    16244  26%  12% mplayer -demuxer aac http://gr-relay-3.gaduradio.pl/45 -ss 0 
 2144  1919 root     R     3044   5%   4% top -d1 
 2096   951 root     R     3044   5%   3% top -d1 
 1918   899 root     S     2348   4%   3% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
  950   899 root     S     2348   4%   2% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
 2229  1138 root     S     276m 461%   0% ./myapplication -qws 
  913     1 root     S    16628  27%   0% /usr/bin/commserver 
 2292  2289 root     S    15984  26%   0% mplayer -demuxer aac http://gr-relay-3.gaduradio.pl/45 -ss 0 
  951   950 root     S     3044   5%   0% -sh 
 1919  1918 root     S     3044   5%   0% -sh 
 1138  1137 root     S     3044   5%   0% -sh 
  902     1 root     S     2928   5%   0% /sbin/syslogd -n -C64 -m 20 
  860     1 root     S     2868   5%   0% udhcpc -R -n -p /var/run/udhcpc.eth0.pid -i eth0 
  904     1 root     S     2864   5%   0% /sbin/klogd -n 
 1137   899 root     S     2348   4%   0% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
  899     1 root     S     2172   4%   0% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
  909     1 root     S     1904   3%   0% /usr/sbin/bftpd -d 
  929     1 root     S     1828   3%   0% /sbin/getty 115200 ttySAC0 
  306     1 root     S <   1808   3%   0% /sbin/udevd -d 
    1     0 root     S     1572   3%   0% init [5]   
  280     2 root     SWN      0   0%   0% [jffs2_gcd_mtd4]
  135     2 root     SW       0   0%   0% [pdflush]
  136     2 root     SW<      0   0%   0% [kswapd0]
    5     2 root     SW<      0   0%   0% [khelper]
    4     2 root     SW<      0   0%   0% [events/0]
    2     0 root     SW<      0   0%   0% [kthreadd]
    3     2 root     SW<      0   0%   0% [ksoftirqd/0]
  102     2 root     SW<      0   0%   0% [kblockd/0]
  109     2 root     SW<      0   0%   0% [kseriod]
  112     2 root     SW<      0   0%   0% [kmmcd]
  134     2 root     SW       0   0%   0% [pdflush]
  137     2 root     SW<      0   0%   0% [aio/0]
  138     2 root     SW<      0   0%   0% [nfsiod]
  210     2 root     SW<      0   0%   0% [mtdblockd]
  272     2 root     SW<      0   0%   0% [rpciod/0]
And now, when it does not start:
Code:
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
 2096   951 root     S     3044   5%   4% top -d1 
 2293  1919 root     R     3044   5%   4% top -d1 
  950   899 root     S     2348   4%   2% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
 1918   899 root     S     2348   4%   1% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
 2229  1138 root     S     277m 462%   0% ./myapplication -qws 
  913     1 root     S    16628  27%   0% /usr/bin/commserver 
  951   950 root     S     3044   5%   0% -sh 
 1919  1918 root     S     3044   5%   0% -sh 
 1138  1137 root     S     3044   5%   0% -sh 
  902     1 root     S     2928   5%   0% /sbin/syslogd -n -C64 -m 20 
  860     1 root     S     2868   5%   0% udhcpc -R -n -p /var/run/udhcpc.eth0.pid -i eth0 
  904     1 root     S     2864   5%   0% /sbin/klogd -n 
 1137   899 root     S     2348   4%   0% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
  899     1 root     S     2172   4%   0% /usr/sbin/dropbear -r /etc/dropbear/dropbear_rsa_host_key -p 22 
  909     1 root     S     1904   3%   0% /usr/sbin/bftpd -d 
  929     1 root     S     1828   3%   0% /sbin/getty 115200 ttySAC0 
  306     1 root     S <   1808   3%   0% /sbin/udevd -d 
    1     0 root     S     1572   3%   0% init [5]   
  280     2 root     SWN      0   0%   0% [jffs2_gcd_mtd4]
  135     2 root     SW       0   0%   0% [pdflush]
  136     2 root     SW<      0   0%   0% [kswapd0]
    5     2 root     SW<      0   0%   0% [khelper]
    4     2 root     SW<      0   0%   0% [events/0]
    2     0 root     SW<      0   0%   0% [kthreadd]
    3     2 root     SW<      0   0%   0% [ksoftirqd/0]
  102     2 root     SW<      0   0%   0% [kblockd/0]
  109     2 root     SW<      0   0%   0% [kseriod]
  112     2 root     SW<      0   0%   0% [kmmcd]
  134     2 root     SW       0   0%   0% [pdflush]
  137     2 root     SW<      0   0%   0% [aio/0]
  138     2 root     SW<      0   0%   0% [nfsiod]
  210     2 root     SW<      0   0%   0% [mtdblockd]
  272     2 root     SW<      0   0%   0% [rpciod/0]
in ps myapplication, in current session, my application has id 2229, so find / -name limits | grep 2229 gives:

Code:
/proc/2229/task/2229/limits
/proc/2229/task/2232/limits
/proc/2229/task/2236/limits
/proc/2229/task/2237/limits
/proc/2229/task/2238/limits
/proc/2229/task/2239/limits
/proc/2229/task/2240/limits
/proc/2229/task/2241/limits
/proc/2229/task/2242/limits
/proc/2229/task/2243/limits
/proc/2229/task/2244/limits
/proc/2229/task/2245/limits
/proc/2229/task/2246/limits
/proc/2229/task/2247/limits
/proc/2229/task/2251/limits
/proc/2229/task/2252/limits
/proc/2229/task/2253/limits
/proc/2229/task/2254/limits
/proc/2229/task/2255/limits
/proc/2229/task/2256/limits
/proc/2229/task/2257/limits
/proc/2229/task/2258/limits
/proc/2229/task/2259/limits
/proc/2229/task/2260/limits
/proc/2229/task/2261/limits
/proc/2229/task/2262/limits
/proc/2229/task/2263/limits
/proc/2229/limits
The multitude (as well as more than 100% VSZ size) of tasks is due to few plug-ins loaded. All of these tasks have the same limits, which are (cat /proc/2229/task/<number>/limits and cat /proc/2229/limits):

Code:
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            ms        
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    0                    bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             512                  512                  processes 
Max open files            1024                 1024                 files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       512                  512                  signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us
Hope this information is important and useful for solution. Please, if anyone has some thoughts on that, write them here.

Thank You in advance,

Thank You.

Last edited by Krzysztow; 04-22-2010 at 05:11 AM. Reason: Additional information
 
Old 04-22-2010, 05:10 AM   #10
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
doubled the message, sorry

Last edited by Krzysztow; 04-22-2010 at 05:12 AM. Reason: doubled message
 
Old 04-22-2010, 06:32 AM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
What exactly are 'mplayer' exit code and error messages when it cannot be launched ?
 
Old 04-22-2010, 06:44 AM   #12
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Sergei Steshenko View Post
What exactly are 'mplayer' exit code and error messages when it cannot be launched ?
I tried to get these outputs by sending them to a file after the process is created:

Code:
   Process *process=new Process(this);

   process->setStandardErrorFile("errorFile", QIODevice::Append);
   process->setStandardOutputFile("errorFile", QIODevice::Append);
And the ouptut is there, when the program runs. However when fails to start, there is nothing appended to the file.

In a second I will check what is the exit status.
 
Old 04-22-2010, 07:27 AM   #13
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
So... when the process starts and ends normally, then the results are:

exit code: 1;
and exit status: QProcess::NormalExit;

When failes to start, there is not finishedSignal(int, QProcess:ExitStatus) emitted, so I can't get the exit code and status.

Thanks,
 
Old 04-22-2010, 07:35 AM   #14
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Krzysztow View Post
So... when the process starts and ends normally, then the results are:

exit code: 1;
and exit status: QProcess::NormalExit;

When failes to start, there is not finishedSignal(int, QProcess:ExitStatus) emitted, so I can't get the exit code and status.

Thanks,
Normal process exit code is 0.
 
Old 04-22-2010, 07:43 AM   #15
Krzysztow
Member
 
Registered: Apr 2010
Posts: 31

Original Poster
Rep: Reputation: 15
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.
 
  


Reply

Tags
embedded, linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xpert in 8-16 bit microcontroller embedded system now inclining toward embedded linux priyadarshan Linux - Embedded & Single-board computer 2 02-12-2009 04:28 AM
LXer: Embedded Linux as Dependable for Developers as RTOSes, says Embedded Market For LXer Syndicated Linux News 0 01-23-2008 11:40 AM
Qt 4 QProcess help dimah Programming 1 05-05-2007 07:03 AM


All times are GMT -5. The time now is 09:10 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration