execl in child process works for only in specific cases

I have been bussy for the last five hours with this problem so I hope someone can help me out. In my C++ program (which I develop in QTcreator on lubuntu) I want to run airodump-ng in the child process of my program. The output of airodump-ng should be directed to the STDOUT of the parent proces. This works with many other programs but strangly enough not with airodump-ng. My Linux crashes when I try to do this with airodump-ng. I get logged out and when I log back in all my programs are closed. Does anybody know why?

#include <QCoreApplication>
#include <unistd.h>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <sys/wait.h>

using namespace std;

int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);
    //execl("/usr/sbin/airodump-ng", "airodump-ng", (char*)0 );
    //dup2(1, 2); //pipe stderr to stdout

    pid_t pidAirodump;
    pid_t pidAircrack;
    int pip[2];

    if (pipe(pip) < 0) {
        perror("allocating pipe for child input redirect");
        return -1;

    pidAirodump = fork();
    if(pidAirodump > 0)//parent
        pidAircrack = fork();
        if(pidAircrack == 0)//pidAircrack
            dup2(pip[1], 2);
            cout << "test" << endl;

            //execl("/usr/sbin/arp", "arp", (char*)0 );
             execl("/usr/sbin/airodump-ng", "airodump-ng ", "mon0", (char*)0 );
    return a.exec();

Source: bash

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.