Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

VFork

Hello,

I tried to compile a small example and I get an error (implicit declaration vfork()). Is it possible to create a new process with uClinux. An other point, i'm usign Nios IDE to compile my application.

int main() {

int taille, lecture, i;

struct sockaddr_in serveur;

char tampon[1024];

int nds, ds;

signal(SIGINT, intercept);

if ((ds = socket(AF_INET, SOCK_STREAM, 0 )) < 0) exit(1);

serveur.sin_family = AF_INET;

serveur.sin_addr.s_addr = INADDR_ANY;

serveur.sin_port = SERV_PORT;

if (bind(ds, (struct sockaddr *)&serveur, sizeof serveur) < 0) exit(1);

taille = sizeof(serveur);

if (getsockname(ds, (struct sockaddr *)&serveur, &taille) < 0 ) exit(1);

listen(ds, 5);

while (1) {

if (( nds = accept(ds, (struct sockaddr *)0, (int *)0)) == -1 ) exit(1);

if (vfork() == 0) { // ERROR HERE!!!!

if ((lecture = read(nds, tampon, 6))==-1) exit(1);

printf("Je viens de lire: %s\n", tampon);

exit(0);

}

}

}