Is there an API in the C++ (or STL) to fetch the parent process id? if not then what could be the portable code to do so? I understand there linux api such as getppid can do the job on unix platforms but what is equivalent of the same on windows?  Thanks!
24544
I'm currently passing the pid on the command line to the child, but is there a way to do this in the Win32 API?  Alternatively, can someone alleviate my fear that the pid I'm passing might belong to another process after some time if the parent has died?
79668
I want to create a communication between a parent and a child process, both written in C#. It should be asynchronous, event-driven. I don't want to run a thread in every process to handle the very rare communication. What is the best solution for it?
53606
I need to write a function that generates an id that is unique for a given machine running a Windows OS.  Currently, I'm using WMI to query various hardware parameters and concatenate them together and hash them to derive the unique id. My question is, what are the suggested parameters I should use?  Currently, I'm using a combination of bios\cpu\disk data to generate the unique id. And am using the first result if multiple results are there for each metric.  However, I ran into an issue where a machine that dual boots into 2 different Windows OS generates different site codes on each OS, which should ideally not happen.  For reference, these are the metrics I'm currently using:  Win32_Processor:UniqueID,ProcessorID,Name,Manufacturer,MaxClockSpeed Win32_BIOS:Manufacturer Win32_BIOS:SMBIOSBIOSVersion,IdentificationCode,SerialNumber,ReleaseDate,Version Win32_DiskDrive:Model, Manufacturer, Signature, TotalHeads Win32_BaseBoard:Model, Manufacturer, Name, SerialNumber Win32_VideoController:DriverVersion, Name
19828
I've seen several of answers about using  or , but I would like to be able to find out in my own code (C#) which process is locking a file. I have a nasty feeling that I'm going to have to spelunk around in the win32 API, but if anyone has already done this and can put me on the right track, I'd really appreciate the help. Update Links to similar questions
63185
I am trying to examine the output from pstree command. But for some reason it always starts from something called as systemd as opposed to it being init. I have checked to see the process ID's of both init and systemd using ps aux command and init has a PID of 1, while systemd has some other PID. So why isn't init being shown in my pstree's output? Is there an option that I need to give?  Also I did read about systemd vs init controversy, but ubuntu 16.04 LTS still uses init to start everything right?  Update as to why different PIDs?  It turns out that different PIDs that I thought were part of my ignorance. The init had a PID 1, whereas systemd wasn't the thing that I was talking about. Instead when I ran ps aux|grep systemd, I found PIDs for /lib/systemd/systemd-*, where * means some extra characters. So what I was talking about was not systemd, but some other processes that were extensions(is it the correct word?) of systemd I guess.  Some of the examples for that * are as follows  /lib/systemd/systemd-journald /lib/systemd/systemd-udevd /lib/systemd/systemd-timesyncd
62538
I get "Access denied" when trying to end a process on Windows 8.  From  on Stack Overflow, I've read:     The process may have a thread active in kernel mode that is not exiting. Best way to diagnose that is by using Task Manager, Details tab, right-click one of the column headers and choose "Select Columns". Tick "Handles". Look at the displayed value for the process. If you see a non-zero value then the process is very likely to have a handle opened and is waiting for a device driver to perform an I/O request. And that device driver is otherwise impervious to Windows asking it to cancel the request. Narrowing down the troublemaker is not that easy, you have to know more about exactly what kind of I/O requests your process performs. Follow up on this by asking a question about it at superuser.com*   So yeah... this problem has accured to the following programs:    Spotify Skype Battlefield 3   I've checked that I have full permission on everything. Even added "Everyone" with full access.   The other solution involved something with C++ which I have no clue about.  I have tried asking support on Microsoft sites but they only told me to go to Security and add everyone with full access.
47434
Is there any command in Linux to figure out, given a process, which processor the process is running? I am interested in figuring out the CPU busy and CPU idle time of that processor.
50216
Does any one know how do I get the current open windows or process of a local machine using Java?    What I'm trying to do is: list the current open task, windows or process open, like in  Windows Taskmanager, but using a multi-platform approach - using only Java if it's possible.
103508
I've a very specific question about fork system call. I've this piece of code:  int main (void)  {     for (int i = 0; i &lt; 10; i++) {         pid_t pid = fork ();          if ( !pid ) {             printf("CHILD | PID: %d, PPID: %d\n", getpid(), getppid());             _exit(i + 1);         }      }      for (int i = 0; i &lt; 10; i++) {         int status;         waitpid(-1, &amp;status, 0);          if (WIFEXITED(status)) {             printf("IM %d AND CHILD WITH EXIT CODE %d TERMINATED\n",                     getpid(), WEXITSTATUS(status));          }          else {             printf("ERROR: CHILD NOT EXITED\n");         }     }      return 0; }   which produces this output:  CHILD | PID: 3565, PPID: 3564 CHILD | PID: 3566, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 1 TERMINATED IM 3564 AND CHILD WITH EXIT CODE 2 TERMINATED CHILD | PID: 3573, PPID: 3564 CHILD | PID: 3567, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 9 TERMINATED IM 3564 AND CHILD WITH EXIT CODE 3 TERMINATED CHILD | PID: 3568, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 4 TERMINATED CHILD | PID: 3569, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 5 TERMINATED CHILD | PID: 3570, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 6 TERMINATED CHILD | PID: 3571, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 7 TERMINATED CHILD | PID: 3572, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 8 TERMINATED CHILD | PID: 3574, PPID: 3564 IM 3564 AND CHILD WITH EXIT CODE 10 TERMINATED   which makes me wonder how fork really works and what code new processes really execute. Looking at the above output results, I can not understand:   How does second for cycle prints before first for finish all iterations? I've also noticed this second for is always executed by parent process, which makes me wonder if while on first for cycle, if pid != 0 (which means parent process calling) second for cycle is executed (?) Why does CHILD processes are not sorted printed by PID?   So, bottom line, how does fork really works and who executes what?
82849
I'm trying to capture all of the output of a build operation, and send it to myprogram. I seem to only be able to capture part of it. This is what I'm trying:  make clean &amp;&amp; make DISABLE_ID3TAG=1 CFLAGS="-O2 -DNDEBUG -W64" | myprogram &amp;2 &gt; 1   I also tried:  make clean &amp;&amp; make DISABLE_ID3TAG=1 CFLAGS="-O2 -DNDEBUG -W64" &amp;2 &gt; 1 | myprogram   Basically I want to send everything to stdout and then do something with that. Currently I'm only capturing part of the output, and the other part is going to the screen. How can I pipe everything to another program?
73556
How do I launch an app and capture the output via stdout and maybe stderr?  I am writing an automated build system and I need to capture the output to analyze. I'd like to update the svn repo and grab the revision number so I can move the files in autobuild/revNumber/ if successful. I also would like to build using make and upload the compile text to my server for everyone to see the warnings and errors on a failed build.  I can't find the system() function, but I found the CreateProcess() function on MSDN. I am able to launch what I need but I have no idea how to capture the stderr and stdout.  I notice the process launches separately unless I set a breakpoint and keep my app exiting which it then will keep all the text in my app console window. I would also want to wait until all processes are finished and then scan the data it produced to do any additional operations I need. How do I do any of this?
81477
Is it possible to set a new nice level of a running process with a known id?  Does this operation require root access, or just being the owner of the process?
32075
I was looking a lot for method to get parent process in .NET, but found only P/Invoke way.
107129
I'm trying to get a list of processes currently owned by the current user (Environment.UserName). Unfortunately, the Process class doesn't have any way of getting the UserName of the user owning a process.  How do you get the UserName of the user which is the owner of a process using the Process class so I can compare it to Environment.UserName?   If your solution requires a pinvoke, please provide a code example.
46309
I just wrote the following C++ function to programatically determine how much RAM a system has installed.  It works, but it seems to me that there should be a simpler way to do this.  Can someone tell me if I'm missing something?  getRAM() {     FILE* stream = popen( "head -n1 /proc/meminfo", "r" );     std::ostringstream output;     int bufsize = 128;      while( !feof( stream ) &amp;&amp; !ferror( stream ))     {         char buf[bufsize];         int bytesRead = fread( buf, 1, bufsize, stream );         output.write( buf, bytesRead );     }     std::string result = output.str();      std::string label, ram;     std::istringstream iss(result);     iss &gt;&gt; label;     iss &gt;&gt; ram;      return ram; }   First, I'm using popen("head -n1 /proc/meminfo") to get the first line of the meminfo file from the system.  The output of that command looks like     MemTotal:       775280 kB   Once I've got that output in an istringstream, it's simple to tokenize it to get at the information I want.  My question is, is there a simpler way to read in the output of this command?  Is there a standard C++ library call to read in the amount of system RAM?
97765
In Linux, we have the "which" command to find out the path of an executable. What is its Windows equivalent? Is there any PowerShell command for doing that?
118279
I'm creating child processes with fork() in C/C++. When the parent process ends (or is killed for some reason) I want all child processes to be killed as well. Is that done automatically by the system? Or I have to do it myself?  Thanks.    Pre-existing similar questions: