polybar/include/utils/proc.hpp

39 lines
855 B
C++
Raw Normal View History

#pragma once
2016-05-19 14:41:06 +00:00
#include <string>
#include <errno.h>
#include <cstring>
#include <signal.h>
#include "exception.hpp"
#define PIPE_READ 0
#define PIPE_WRITE 1
namespace proc
{
class ExecFailure : public Exception {
using Exception::Exception;
};
pid_t get_process_id();
// pid_t get_parent_process_id();
2016-05-19 14:41:06 +00:00
bool in_parent_process(pid_t pid);
bool in_forked_process(pid_t pid);
pid_t fork();
bool pipe(int fds[2]);
2016-06-21 01:59:43 +00:00
void exec(std::string cmd);
2016-05-19 14:41:06 +00:00
bool kill(pid_t pid, int sig = SIGTERM);
pid_t wait(int *status);
pid_t wait_for_completion(pid_t pid, int *status, int options = 0);
pid_t wait_for_completion(int *status, int options = 0);
2016-06-14 10:12:09 +00:00
pid_t wait_for_completion(pid_t pid);
2016-05-19 14:41:06 +00:00
pid_t wait_for_completion_nohang(pid_t pid, int *status);
pid_t wait_for_completion_nohang(int *status);
pid_t wait_for_completion_nohang();
}