Linux2009. 11. 20. 16:23
마지막으로 소스를 대충 보면, wait()를 하는 부분이 없네요. TestA가 daemon 형태로 re-parent한다면 상관없겠지만, 그렇지 않다면 아마 zombie 프로세스가 될 듯 합니다. zombie를 막으려면 daemon 형태로 만들거나, wait()로 child process의 return을 받아야 합니다. 그리고 이 때, SIGCHLD를 비롯, signal 처리를 하려면 pthread_sigmask() 등을 써서, signal을 원하지 않은 thread에서는 해당 시그널이 발생하지 않도록 block시켜야 합니다.

[링크 : http://kldp.org/node/103568]

All of these system calls are used to wait for state changes in a child of the calling process, and obtain information about the child whose state has changed. A state change is considered to be: the child terminated; the child was stopped by a signal; or the child was resumed by a signal. In the case of a terminated child, performing a wait allows the system to release the resources associated with the child; if a wait is not performed, then terminated the child remains in a "zombie" state (see NOTES below).

[링크 : http://linux.die.net/man/2/waitpid]

프로세스 생성하고 parent에서 waitpid 하지 않으면 좀비가 생성된다.
ps 치면 Zombie 들이 우글우글 -ㅁ-
Posted by 구차니
Microsoft/Windows2009. 4. 15. 11:39
VC++ 6.0 기준으로 사용가능한 방법은 아직 찾지 못했다.
리눅스에서는 ps -ef 하면 실행시의 옵션항목(아규먼트)들이 같이 표기 되는데
윈도우에서는 프로그램 이름만 보이게 되어서, 어떠한 옵션으로 실행이 되었는지 궁금해질때가 있다.

그래서 검색을 해보니 .net framework에서는 process 클래스에 startinfo 라는 항목이 존재한다.
이것을 사용하면 argument를 알아 올수 있겠지만, 난 .net을 싫어하는 관계로.. 다른 방법을 찾아 봐야겠다.

using System; 
using System.Diagnostics; 

namespace ProcessArgsTest 
{ 
  class Test 
  { 
    static void Main()  
    { 
      Process [] localAll = Process.GetProcesses(); 
      foreach (Process p in localAll) 
      {   
        if (p.ProcessName == "notepad") 
        { 
          Console.WriteLine(p.ProcessName + " [" + p.StartInfo.Arguments + "]"); 
        } 
      } 
    } 
  } 
} 


[발견 : http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/669eeaeb-e6fa-403b-86fd-302b24c569fb/]
[process.GetProcesses method : http://msdn.microsoft.com/en-us/library/1f3ys1f9.aspx]
[process.StartInfo method : http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo.aspx]
Posted by 구차니