2015-05-15 05:44:48 +08:00
|
|
|
/*
|
|
|
|
|
|
|
|
nsjail - subprocess management
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
Copyright 2014 Google Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2016-03-02 00:03:11 +08:00
|
|
|
|
2016-03-11 09:45:43 +08:00
|
|
|
#ifndef NS_PROC_H
|
|
|
|
#define NS_PROC_H
|
2015-05-15 05:44:48 +08:00
|
|
|
|
2016-10-15 08:42:01 +08:00
|
|
|
#include <inttypes.h>
|
2017-10-18 20:46:17 +08:00
|
|
|
#include <stdbool.h>
|
2016-10-15 08:42:01 +08:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-02-11 11:02:14 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-10-18 20:46:17 +08:00
|
|
|
#include "nsjail.h"
|
|
|
|
|
2018-02-10 00:03:02 +08:00
|
|
|
namespace subproc {
|
|
|
|
|
2020-08-31 04:02:08 +08:00
|
|
|
/* 0 - network connection limit reached, -1 - error */
|
|
|
|
pid_t runChild(nsjconf_t* nsjconf, int listen_fd, int fd_in, int fd_out, int fd_err);
|
2018-02-10 22:50:12 +08:00
|
|
|
int countProc(nsjconf_t* nsjconf);
|
|
|
|
void displayProc(nsjconf_t* nsjconf);
|
2018-07-27 19:33:39 +08:00
|
|
|
void killAndReapAll(nsjconf_t* nsjconf);
|
2018-02-10 00:03:02 +08:00
|
|
|
/* Returns the exit code of the first failing subprocess, or 0 if none fail */
|
2018-02-10 22:50:12 +08:00
|
|
|
int reapProc(nsjconf_t* nsjconf);
|
2018-02-11 11:02:14 +08:00
|
|
|
int systemExe(const std::vector<std::string>& args, char** env);
|
2018-02-10 01:45:50 +08:00
|
|
|
pid_t cloneProc(uintptr_t flags);
|
2018-02-10 00:03:02 +08:00
|
|
|
|
|
|
|
} // namespace subproc
|
|
|
|
|
2017-10-09 05:00:45 +08:00
|
|
|
#endif /* NS_PROC_H */
|