process.h (1634B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style license that can be 5 // found in the LICENSE file. 6 7 #ifndef BASE_PROCESS_H_ 8 #define BASE_PROCESS_H_ 9 10 #include "base/basictypes.h" 11 12 #include <sys/types.h> 13 #ifdef XP_WIN 14 # include <windows.h> 15 #endif 16 17 namespace base { 18 19 // ProcessHandle is a platform specific type which represents the underlying OS 20 // handle to a process. 21 // ProcessId is a number which identifies the process in the OS. 22 #if defined(XP_WIN) 23 typedef HANDLE ProcessHandle; 24 typedef DWORD ProcessId; 25 // inttypes.h-like macro for ProcessId formatting. 26 # define PRIPID "lu" 27 28 const ProcessHandle kInvalidProcessHandle = INVALID_HANDLE_VALUE; 29 30 // In theory, on Windows, this is a valid process ID, but in practice they are 31 // currently divisible by four. Process IDs share the kernel handle allocation 32 // code and they are guaranteed to be divisible by four. 33 // As this could change for process IDs we shouldn't generally rely on this 34 // property, however even if that were to change, it seems safe to rely on this 35 // particular value never being used. 36 const ProcessId kInvalidProcessId = kuint32max; 37 #else 38 // On POSIX, our ProcessHandle will just be the PID. 39 typedef pid_t ProcessHandle; 40 typedef pid_t ProcessId; 41 // inttypes.h-like macro for ProcessId formatting. 42 # define PRIPID "d" 43 44 const ProcessHandle kInvalidProcessHandle = -1; 45 const ProcessId kInvalidProcessId = -1; 46 #endif 47 48 } // namespace base 49 50 #endif // BASE_PROCESS_H_