I'm using fork() to create new process.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <ncurses.h>
#include <iostream>
#include <time.h>
int main (void)
{
switch (fork())
{
case -1: exit(0);
case 0: {
execl("Terminal.app", "shell", "-e", "time ls; shell", (char*)0);
break;
}
default: {
std::cout << "OK" << std::endl;
initscr();
time_t secs = time(NULL);
tm* timeInfo = localtime(&secs);
printw("TIME: %s", asctime(timeInfo));
getch();
endwin();
}
}
return 0;
}
This code should create new console window and make time ls, but it doesn't. What is the problem?
open -a Terminal.appinstead of just Terminal.app?-nflag.