Unix to Windows Porting Dictionary for HPC

Links

Function List

getppid


Table of Contents

Unix
Windows
Purpose
Discussion

Unix

header file: unistd.h

pid_t getppid (void);

Windows

header file: n/a

Purpose

This function returns the process ID of the parent of the calling process.

Discussion

On Unix systems the getppid() function allows a child process to learn the PID of its parent process (the process that started it). Typically the parent PID, or PPID, is obtained when the child process wants to send a signal to the parent process. This is often done to tell the parent process the child has finished some action, or that the parent process should take some action. An example of this would be the child process alerting the parent process to a configuration file getting updated.

On Windows there is not a matching function or one with similar functionality. There is a paradigm difference between Unix and Windows. Windows does not maintain the parent-child relationships between processes. And it Windows does not deliver signals to processes.

You will need to examine the source code to determine the reason the child process wants to send a signal to the parent process. This will most likely result in a change of the source code. The code change could be minor (i.e. no longer performing the action) or major (re-structuring of the program). Often when a program changes from Unix to Windows due to a paradigm shift Unix program that ran as more than one process will be changed to a single process that is multi-threaded with a single thread responsible for specific actions. Instead of alerts between processes being delivered by signals, the alerts are now between threads and are delivered by an event.

However, it is possible to obtain obtain the parent process as described at http://www.codeproject.com/KB/threads/ParentPID.aspx?msg=1673927#xx1673927xx.

blog comments powered by Disqus