struct ArgInfo {
enum { tpUNSET, tpCTX, tpPID } type;
- ctx_t ctx;
+ xid_t ctx;
pid_t pid;
unsigned int interval;
bool shutdown;
doKillAll(struct ArgInfo const * const args)
{
size_t i=0;
+ pid_t init_pid = vc_X_getinitpid(0);
signal(SIGSTOP, SIG_IGN);
next_time += atoi(args->argv[i]);
iterateThroughProc(&doKillAllSingle, args, &sig);
+ if (init_pid!=-1 && init_pid>1 && init_pid!=getpid())
+ kill(init_pid, sig);
+
while (time(0)<next_time && getRemainingProcCount(args)>0)
usleep(args->interval * 1000);
Emkdir("old/foo",0600);
Emount("none", "/proc", "proc", 0, 0);
+ // TODO: drop additional capabilities?
+
// TODO: it may be be better for ctx-shutdown to:
// * generate ctx with S_CTX_INFO_INIT
// * send kill to -1
return 0;
}
-static ctx_t
+static xid_t
determineContext(pid_t pid)
{
int fd[2];
pid_t chld;
- ctx_t res;
+ xid_t res;
Epipe(fd);
chld = Efork();
if (args.type==tpPID)
args.ctx = determineContext(args.pid);
+
+ if (args.ctx==0) {
+ WRITE_MSG(2, "Can not operate in ctx 0\n");
+ return EXIT_FAILURE;
+ }
args.argc = argc-optind;
args.argv = argv+optind;