0

hello
i'm writing a program in c++ and i'm using linux.
i use fork() in order to create a process and then i want to wait for the child process
to finish so its something like that:

pid=fork();
      if(pid<0)
      {
	cerr << "Failed to fork" << endl;
	exit(1);
       }
	if(pid==0){
	 /*do what you have to do*/		
	 exit(0);
	}
	int status;
	wait(&status);

the thing is that it doesnt accept this syntax of wait()
which is really strange as in C works fine.
can anybody tell me whats wrong?

Edited by vyrte: n/a

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by iamthesgt
0

it tells me that "status" was previously declared although i havent declared it anywhere. maybe its something wrong with the libraries included.these are the libraries i include below:
#include<stdio.h>
#include <iostream>
#include<string.h>
#include <poll.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <fstream>
#include <sys/times.h>
#include <unistd.h>

Edited by vyrte: n/a

0

I would venture to guess that one of those libraries has declared 'status as a variable or function. Try changing the name to something like 'mystatus' or 'waitstatus' and see if you still get an error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.