Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

VFork

Altera_Forum
Honored Contributor II
1,015 Views

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); 

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
307 Views

You forgot to indicate which files you&#39;re including -- vfork requires sys/types.h and unistd.h

0 Kudos
Altera_Forum
Honored Contributor II
307 Views

Incidentally, 

 

from the uclinux faq (http://www.uclinux.org/pub/uclinux/faq.shtml#2-5)
0 Kudos
Reply