mirror of
https://github.com/springzfx/cgproxy.git
synced 2026-01-07 13:07:56 +08:00
24 lines
493 B
C++
24 lines
493 B
C++
#include "cgroup_attach.hpp"
|
|
using namespace std;
|
|
|
|
void print_usage() { fprintf(stdout, "usage: cgattach <pid> <cgroup>\n"); }
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int flag=setuid(0);
|
|
if (flag!=0) {
|
|
perror("cgattach need root");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
if (argc != 3) {
|
|
error("need exact 2 paramaters");
|
|
print_usage();
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
string pid = string(argv[1]);
|
|
string cgroup_target = string(argv[2]);
|
|
|
|
CGPROXY::CGROUP::attach(pid,cgroup_target);
|
|
}
|