2009-07-08 13:19:16 -07:00
|
|
|
/*
|
2013-05-08 14:11:27 -07:00
|
|
|
* Copyright (c) 2008, 2009, 2011, 2013 Nicira, Inc.
|
2009-07-08 13:19:16 -07:00
|
|
|
*
|
2009-06-15 15:11:30 -07:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
2009-07-08 13:19:16 -07:00
|
|
|
*
|
2009-06-15 15:11:30 -07:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-07-08 13:19:16 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PROCESS_H
|
|
|
|
#define PROCESS_H 1
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
struct process;
|
2013-05-08 15:02:45 -07:00
|
|
|
|
2017-06-20 10:29:47 +01:00
|
|
|
struct process_info {
|
|
|
|
unsigned long int vsz; /* Virtual size, in kB. */
|
|
|
|
unsigned long int rss; /* Resident set size, in kB. */
|
|
|
|
long long int booted; /* ms since monitor started. */
|
|
|
|
int crashes; /* # of crashes (usually 0). */
|
|
|
|
long long int uptime; /* ms since last (re)started by monitor. */
|
|
|
|
long long int cputime; /* ms of CPU used during 'uptime'. */
|
2017-11-08 20:49:26 +00:00
|
|
|
int core_id;
|
|
|
|
char name[18];
|
2017-06-20 10:29:47 +01:00
|
|
|
};
|
|
|
|
|
2013-05-08 15:02:45 -07:00
|
|
|
/* Starting and monitoring subprocesses.
|
|
|
|
*
|
|
|
|
* process_init() and process_start() may safely be called only from a
|
|
|
|
* single-threaded parent process. The parent process may safely create
|
|
|
|
* additional threads afterward, as long as the remaining functions in this
|
|
|
|
* group are called only from a single thread at any given time. */
|
2009-07-08 13:19:16 -07:00
|
|
|
void process_init(void);
|
2013-05-08 14:31:55 -07:00
|
|
|
int process_start(char **argv, struct process **);
|
2009-07-08 13:19:16 -07:00
|
|
|
void process_destroy(struct process *);
|
|
|
|
int process_kill(const struct process *, int signr);
|
|
|
|
pid_t process_pid(const struct process *);
|
|
|
|
const char *process_name(const struct process *);
|
|
|
|
bool process_exited(struct process *);
|
|
|
|
int process_status(const struct process *);
|
2013-06-06 16:26:34 -07:00
|
|
|
void process_run(void);
|
2009-07-08 13:19:16 -07:00
|
|
|
void process_wait(struct process *);
|
|
|
|
|
2017-06-20 10:29:47 +01:00
|
|
|
int count_crashes(pid_t);
|
|
|
|
bool get_process_info(pid_t, struct process_info *);
|
|
|
|
|
2013-05-08 15:02:45 -07:00
|
|
|
/* These functions are thread-safe. */
|
|
|
|
char *process_status_msg(int);
|
|
|
|
char *process_escape_args(char **argv);
|
2009-07-08 13:19:16 -07:00
|
|
|
char *process_search_path(const char *);
|
|
|
|
|
|
|
|
#endif /* process.h */
|