static char *ename = NULL;
static const char *oname = NULL;
+static int isPipeOwner = 0;
+
static struct option long_options[] = {
- {"appid", required_argument, 0, 'a'},
- {"pipe", required_argument, 0, 'p'},
- {"exec", required_argument, 0, 'e'},
- {"error", required_argument, 0, 'o'},
- {"timeout", required_argument, 0, 't'},
- {"verbose", no_argument, 0, 'v'},
- {"list", no_argument, 0, 'l'},
- {"info", no_argument, 0, 'i'},
+ {"appid", required_argument, 0, 'a'},
+ {"pipe", required_argument, 0, 'p'},
+ {"exec", required_argument, 0, 'e'},
+ {"error", required_argument, 0, 'o'},
+ {"timeout", required_argument, 0, 't'},
+ {"verbose", no_argument, 0, 'v'},
+ {"list", no_argument, 0, 'l'},
+ {"info", no_argument, 0, 'i'},
+ {"pipe-owner", no_argument, 0, 'w'},
{0, 0, 0, 0}
};
tcsetattr(0,TCSANOW, &sterm);
if (tf != NULL) {
fclose(tf);
- unlink(pname);
+ if (isPipeOwner) {
+ unlink(pname);
+ }
}
kill(getpid(), SIGKILL);
}
{
int option_index;
- switch(getopt_long(argc, argv, "-a:p:vle:o:it:",
+ switch(getopt_long(argc, argv, "-a:p:vle:o:it:w",
long_options, &option_index)) {
case 1:
if (appid == NULL) {
case 'l': ListApps(0); exit(0);
case 'i': doinfo = 1; break;
case 't': timeout = atoi(optarg); break;
+ case 'w': isPipeOwner = 1; break;
default:
return -1;
}
freopen(oname, "w", stderr);
setbuf(stderr, NULL);
- if (pname) {
+ if (pname && isPipeOwner) {
unlink(pname);
if (mkfifo(pname, 0666)) {
perror("mkfifo");