Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #621 from devimc/topic/agent/revert585
Browse files Browse the repository at this point in the history
revert: agent: sandbox_pause should get arguments from proc
  • Loading branch information
Julio Montes authored Aug 2, 2019
2 parents d6d8514 + 72a50ef commit 7750d5d
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,18 @@ package main
/*
#cgo CFLAGS: -Wall
#define _GNU_SOURCE
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#define PAUSE_BIN "pause-bin"
void __attribute__((constructor)) sandbox_pause(void) {
FILE *f;
int len, do_pause = 0;
size_t n = 0;
char *p = NULL;
f = fopen("/proc/self/cmdline", "r");
if (f == NULL) {
perror("failed to open proc");
exit(-errno);
}
while ((len = getdelim(&p, &n, '\0', f)) != -1) {
if (len == sizeof(PAUSE_BIN) && !strncmp(p, PAUSE_BIN, sizeof(PAUSE_BIN)-1)) {
do_pause = 1;
break;
}
}
fclose(f);
free(p);
if (do_pause == 0)
void __attribute__((constructor)) sandbox_pause(int argc, const char **argv) {
if (argc != 2 || strcmp(argv[1], PAUSE_BIN)) {
return;
}
for (;;) pause();
Expand Down

0 comments on commit 7750d5d

Please sign in to comment.