So, I'm coming back from my child's thread I'm using the _exit () system call I was thinking about a few things for my child _ what was a parameter for the extension, here is the code that my child is performing the process:
printf ("\ n ** ** Hair Process. **** \ n \ nInformation: "); Print integer in the {// sequence printf ("% d \ t", inputInteger); If ((Input Integer% 2) == 0) {// printf ("inputInteger =% d \ n", inputInteger); InputInteger = inputInteger / 2; } And {inputInteger = 3 * inputInteger +1; // printf ("% d \ t", inputInteger); }} While (inputInteger! = 1); // Make sure we print off 1! Printf ("% d \ n \ n", input teaser); // right exit (position);
I use the condition because I use it in the waitpid () system call in my parent's thread. Here is the code for the basic procedure that is executed after the child completes.
waitpid_check = waitpid (processID, and position, 0); Printf ("\ n **** Parental Process. **** \ n"); If (waitpid_check == -1) {printf ("Error Waiting. \ N"); Exhaust (EXIT_FAILURE); } If (wifaxed (position)) {printf ("hair process normally ends! \ N"); }
Here I am using the waitpid () system call which ensures that the child was out, then use the condition to check whether it is properly Was out. I was wondering if I was going to make the baby about it and in the right way to get it out.
Still I was wondering if I was checking the child out of the child in the right way.
Thank you for your help!
WaitingPad from Linux manual
"If the condition is not zero, wait () and waitpid () store status information indicates which int."
You do not need the return value of waiting for the payment to check if the child failed. You have to check the value of the situation There are some macros to check the situation.
WITNESS return true if the child normally ends, i.e., by calling (3) or _extension (2) or returning to main () WEXITSTATUS (status) ) Gives the child's exhaust condition in it there are at least 8 bits of the logic of the position that the child has to be referred to as the argument of return statement in call (3) or _ext (2) or main () has gone. This macro should be employed only if Vigharde returns the truth. Wifsglad (status) returns true if the hair process is eliminated by the signal, the number of WTERMSIG (status) signal gives the child's process finished. This macro should be employed only if WiFiCGlide returns right. WCOREDUMP (status) Returns right if the child produced a core dump. This macro should be employed only if WiFiCGlide returns right. This macro is not specified in POSIX.1-2001 and is not available on some Unix deployment (e.g., AIX, SunOS). Only use it #ifdef WCOREDUMP ... Attach to #endif WIFSTOPPED (status) returns true if the hair process was stopped from the delivery of the signal; This is only possible if the call was used in a wuntraced or when it was being detected (see ptrace (2)). The WSTOPSIG (status) gives the number of signs which caused the child to stop. This macro should be employed only when WIFCOPINTED (status) since the WIFCONTINUED (status) since the WIFSTOPPED is correct, if the infant process was started by delivery of SIGCONT.
Whether you are going out of the baby's process or not, it is really true that you come out of any other program, when you make a process , You actually have to replace an address and run the child as your independent program (as a single open FD, already declared value etc.) as a parent. Below is a specific implementation for this problem (though the tap is being passed in wait instead of the situation, so I think you are correcting it.)
/ * A hair process Fork * / pid = fork (); If (pid & lt; 0) {/ * error occurred * / fprintf (stderr, "Fork failed \ n"); Return 1; } And if (pd == 0) {/ * hair process * / printf ("I'm a child% d \ n", pid); Execlp ("/ bin / ls", "ls", zero); } Other {/ * Basic Process * / / * Parents will wait for the child to complete * / printf ("I have parent \ d \ n", pid); Wait (zero); Printf ("Complete the child \ n"); } Return 0;
Comments
Post a Comment