So I'm a C# developer and I am learning C++ (as hobby).

I use Qt for that, and for practice i want create a FTP client, but I have a problem.

I create an event when the ftp connection state changed, so I want use the event stateChanged(int)

But i have a problem :

Error: no matching function for call to 'QObject::connect(QFtp*&amp;, const char*, Ftp* const, const char*)'


My code :

    #include "ftp.h"

QString _host;
QString _User;
QString _Pass;

Ftp::Ftp(QObject *parent,QString host,QString user,QString pass)
{
    ftp =new QFtp(parent);
    QObject::connect(ftp,SIGNAL(stateChanged(int)),this,SLOT(FtpStateChang(int)));
    _host = host;
    _User = user;
    _Pass = pass;
}

void Ftp::Connect()
{
    ftp-&gt;connectToHost(_host,21);
    ftp-&gt;login(_User,_Pass);
}

void Ftp::FtpStateChang(int state)
{
    //EVENT
}

QString Ftp::CheckConnection()
{
    Connect();
    switch(ftp-&gt;state())
    {
        case QFtp::LoggedIn:
            return "LoggedIn";
        case QFtp::Unconnected:
            return "Unconnected";
        case QFtp::Connecting:
            return "Connecting";
        case QFtp::Closing:
            return "Closing";
    }
}


Please tell me why. Thank you for your help.


Question: Running something in a cron environment?
Answer: 
  "How does this functionality work?"


What you are describing is not really functionality, it's dysfunctionality caused by a misconception. It's not cron that sends the SIGPIPE, but it is because of the way you are using it.

By default cron emails the stdout and stderr of a process to the owner of the crontab using sendmail (see man cron; if you don't have an MTA installed, the output is just discarded), unless they are redirected.  To do this, it must wait for the process to complete.  However, if you have backgrounded the process with &amp;:

* * * * * /bin/someprogram &amp;


It won't wait, and if the program now tries to write to stdout or stderr, it will get a SIGPIPE, because the pipe is broken (the read end was closed). [This might also happen to a non-background process on older crons if your MTA is missing and you have a lot of output]

So I am going to guess that you have something like this in your crontab:

* * * * * /bin/someprogram &gt; log.file &amp;


Meaning the stdout is redirected to a file, but the stderr pipe is still broken.  This has led you to the erroneous conclusion that "cron executes whatever program is sent to it in such a fashion that anything written to STDERR causes ... SIGPIPE".

You can fix your crontab by either removing the backgrounding &amp; or redirecting stderr too:

* * * * * /bin/someprogram 1&gt;&amp;2&amp;&gt; log.file &amp;


If you want.  WRT duplicating this yourself, as qqx says, just close one end of a pipe and then write to it.