Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem With fork and waitpid function call on Solaris 10

807557Sep 19 2009
We have a UNIX box with Solaris 10.It has two application environments (With Two different UNIX users) which have same application deployed.

1. Application component include application daemon, application scheduler and application batch programs.
2. All environment variables are same on both the environments.
3. Versions of application components are same.
4. Libraries (system or application) linked to the components are also same and verified through ldd command.
5. Applications are compiled and build using Sun Studio 12.

With in the application, we an application daemon process running and this on certain condition fork new process which in turn fork and starts new process. New process are forked through fork () function and wait for child is done through wait (&status) function call and after getting child retrun status we do further processing. Child process is given argument through execvp() function call.

Daemon forks scheduler on certain condition and go on sleep. Scheduler fork batch processes. Scheduler is responsible for collection batch program status and do further processing.

In one of environment (env1) this application is running fine without any issue. In other environment (env2) we have following observations

1. Forking is done successful and child processes are started. It is verified through ps command.
2. These child processes do successful execution and return with success. UNIX exit is also verified through truss command for child processes.
3. Parent remains in hang status and it is not able to receive the child return status.


To get out of this problem we tried equivalent by replacing wait (&status) by waitpid (0, &status, NULL) but it also hanged in env2 but it worked in env1.

Further on this we tried by replacing waitpid (0, &status, NULL) with waitpid (-1, &status, 0) but is returning value -1 and error code in errno variable is (10) ECHILD which means “The process or process group specified by pid does not exist or is not a child of the calling process.” Even further to this we tried by passing exact child process id returned from fork () function call waitpid(pid, &status , 0), It returned -1 and errno as 10(ECHILD)
Executing the same version on Env1 does not give any error and any version of wait, waitpid work fine but env2 we are not able to get the child status of process by any function.

Request you to give me some pointer to solution or help us to know the reason of this behavior.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2009
Added on Sep 19 2009
0 comments
408 views