[Qt-interest] QProcess's bug?

邵度 shao.tu at gmail.com
Thu Jun 25 09:58:51 CEST 2009


My program looks like the following:

int main(int argc, char* argv[])
{
  QCoreApplication app(argc, argv);

  if (runInDaemon)
    becomeDaemonFromNowOn();  // By means of traditional unix fork()

  ClassUsesQProcess obj;

  return app.exec();
}

ClassUsesQProcess holds a QProcess and a QTimer as its members.
The QTimer emits timeout() signal every 2 seconds so that it can
periodically run shell commands.

As code above, if runInDaemon is false, everything's okay to do shell
command via QProcess.
If, but, runInDaemon is true, the program will become a daemon first, then
do shell command via QProcess.
In the latter case, QProcess's initial state will be QProcess::Running.
And the shell command, I want to execute, can't be run due to it's in
running state.
( I get its initial state since I check and print its state first everytime
prior to execute shell commands)
How come?

Anybody please figuring it out. Thanks!!



2009/6/25 Andreas Pakulat <apaku at gmx.de>

> On 25.06.09 09:45:32, 邵度 wrote:
> > Hi,
> >
> > My program uses QProcess to periodically execute some shell commands for
> > convenient.
> > When I normally run my program, everything seems okay.
> > While if I run my program in daemon, QProcess always tells me it's state
> is
> > QProcess::Running initially.
>
> What do you mean with "daemon" here? Which program are you talking about -
> the one that uses QProcess or the one that is being started inside the
> QProcess?
>
> > Am I something wrong with QProcess?
> > Should I use fork() and exec() family to achieve my goal instead of
> > QProcess?
>
> Without some sample code nobody can tell you the answer.
>
> Andreas
>
> --
> You will be the last person to buy a Chrysler.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090625/192fdf35/attachment.html 


More information about the Qt-interest-old mailing list