Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created October 19, 2015 18:29
Show Gist options
  • Save ynonp/48eb15db542bbab87bb3 to your computer and use it in GitHub Desktop.
Save ynonp/48eb15db542bbab87bb3 to your computer and use it in GitHub Desktop.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <unistd.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QObject::connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(myfork()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::myfork()
{
int status;
pid_t pid1;
if (( pid1 = fork() ))
{
/* parent process A */
// waitpid(pid1, &status, 0);
}
else if ( !pid1 )
{
execl("/bin/ls", "ls", 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment