computer

프로세스 ID 시스템 콜

유순이 2021. 7. 5. 08:27

getpid() / getppid()

#include <sys/type.h>
#include <unistd.h>

pid_t getpid (void);
pid_t getpid (void);

실습

#include <sys/types.h>
#include <unistd.h>
#include <studio.h>

int main()
{
	printf("pid=%d\n", getpid());
	printf("pid=%d\n", getppid());
    return 0;
}

해당 코드를 컴파일한 뒤,

 

./compliedfile

하면 실행된다.