1/* 2 * Copyright (c) 2011, ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#include <unistd.h> 11#include <assert.h> 12#include "posixcompat.h" 13 14pid_t getpid(void) 15{ 16 domainid_t pid = disp_get_domain_id(); 17 18 // If we don't have a valid domainid (if we're a boot domain), 19 // we fake a pid 20 if(pid == 0) { 21 pid = 3; 22 } 23 24 POSIXCOMPAT_DEBUG("getpid() = %d\n", pid); 25 return pid; 26} 27 28pid_t getppid(void) 29{ 30 char *sppid = getenv("PPID"); 31 int ppid; 32 33 if(sppid == NULL) { 34 // Fake parent ID if not in environment 35 ppid = 2; 36 } else { 37 ppid = atoi(sppid); 38 } 39 40 POSIXCOMPAT_DEBUG("getppid() = %d\n", ppid); 41 return ppid; 42} 43