Created
October 19, 2015 18:29
-
-
Save ynonp/48eb15db542bbab87bb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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