c - How to modify fork () function? -


i new operating systems , working on os project, want know way through can make changes fork function (a function creates child process). don't know whether fork runs on windows or on linux.

i want make changes fork, i.e should print whether child process created or not, purpose somehow needs definition of fork function unable find.

i know exists in <sys/types.h>, don't know where.

i can gives me way or give fork function definition, 'll great, further update self.

you can not modify fork. it's system call (with libc wrapper normally). it's unix specific , not exist in same form in windows.

it returns 1 of 3 possible values:

0) returned in child!

positive number) child process id returned in parent

negative number) failure create child, check errno reasons.

example use:

pid_t child_pid = fork(); if (!child_pid) {     // child goes here } else if (child_pid > 0) {     // parent goes here } else {     // not create child     perror("fork");     abort(); } 

consult man 2 fork more details.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -