On Tue, Jun 14, 2011 at 08:58:08PM +0200, Andre Poenitz wrote:
> On Tue, Jun 14, 2011 at 08:16:49PM +0200, Enrico Forestieri wrote:
> > No, I didn't find anything specific but it is clear that using the QtCore
> > library is not advisable for this task.
> > 
> > > PS I can do the recommit to branch, once it's in trunk.
> > 
> > I committed the fix at r39049. However, I think that the reversion of
> > r38746 was not necessary given that a patch had been already devised.
> 
> I wonder whether it might be possible for you to file
> a proper bug report for that, i.e. some minimal, but
> complete, reproducible example that exhibits that problem
> on bugreports.qt.nokia.com, product "Qt", component
> "core: i/o" (or whatever is close).

I don't have an account (and don't want to have one), so I cannot report
the bug. Maybe someone with an account could do that. I attach here a
simple test case exhibiting the problem.

Problem: When setting the environment of QProcess, a script without
a shebang line fails to execute.

How to reproduce:
1) Save the myprog perl script and test-env.cpp in the same directory.
2) Make executable myprog by "chmod 755 myprog".
3) Compile test-env.cpp without defining SETENV.
4) Launch the just compiled executable and verify that the the script is
   actually executed.
5) Now compile test-env.cpp by using -DSETENV.
6) Launch again the executable and verify that it now fails to execute.

-- 
Enrico
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 
$argv:q'
  if 0;

print "it works";
exit(0);
#include <QProcess>
#include <QDebug>
#include <QtCore>

int main()
{
    QProcess *proc = new QProcess();
#ifdef SETENV
    proc->setEnvironment(QProcess::systemEnvironment());
#endif
    proc->setProcessChannelMode(QProcess::MergedChannels);
    proc->start("./myprog");
    if (proc->waitForFinished())
        qDebug() << "Output:" << proc->readAll();
    else
        qDebug() << "Fail:" << proc->errorString();
    proc->close();
    delete proc;
    return 0;
}

Reply via email to