linux_util.h revision c407dc5cd9bdc5668497f21b26b09d988ab439de
1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef BASE_LINUX_UTIL_H_ 6#define BASE_LINUX_UTIL_H_ 7 8#include <stdint.h> 9#include <sys/types.h> 10 11#include <string> 12 13class FilePath; 14 15namespace base { 16 17class EnvVarGetter; 18 19static const char kFindInodeSwitch[] = "--find-inode"; 20 21// Get the Linux Distro if we can, or return "Unknown", similar to 22// GetWinVersion() in base/win_util.h. 23std::string GetLinuxDistro(); 24 25// Return the inode number for the UNIX domain socket |fd|. 26bool FileDescriptorGetInode(ino_t* inode_out, int fd); 27 28// Find the process which holds the given socket, named by inode number. If 29// multiple processes hold the socket, this function returns false. 30bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode); 31 32// For a given process |pid|, look through all its threads and find the first 33// thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches 34// |expected_data|, where N is the length of |expected_data|. 35// Returns the thread id or -1 on error. 36pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data); 37 38} // namespace base 39 40#endif // BASE_LINUX_UTIL_H_ 41