git://git.onelab.eu
/
util-vserver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util-vserver-0.30.208
[util-vserver.git]
/
src
/
vkill.c
diff --git
a/src/vkill.c
b/src/vkill.c
index
aeabb08
..
02f386a
100644
(file)
--- a/
src/vkill.c
+++ b/
src/vkill.c
@@
-1,4
+1,4
@@
-// $Id: vkill.c,v 1.
1.2.2 2003/12/30 13:49:17
ensc Exp $ --*- c -*--
+// $Id: vkill.c,v 1.
8 2004/08/19 14:30:50
ensc Exp $ --*- c -*--
// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
//
// Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
//
@@
-19,10
+19,10
@@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "compat.h"
#include "vserver.h"
#include "linuxvirtual.h"
#include "vserver.h"
#include "linuxvirtual.h"
+#include "util.h"
#include <getopt.h>
#include <signal.h>
#include <getopt.h>
#include <signal.h>
@@
-35,24
+35,26
@@
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/wait.h>
-#define VERSION_COPYRIGHT_DISCLAIMER
+#define ENSC_WRAPPERS_VSERVER 1
+#define ENSC_WRAPPERS_UNISTD 1
+#include <wrappers.h>
#define CMD_HELP 0x8000
#define CMD_VERSION 0x8001
#define CMD_HELP 0x8000
#define CMD_VERSION 0x8001
-#define WRITE_MSG(FD,X) (void)(write(FD,X,sizeof(X)-1))
-#define WRITE_STR(FD,X) writeStr(FD,X)
+int wrapper_exit_code = 1;
static struct option const
CMDLINE_OPTIONS[] = {
static struct option const
CMDLINE_OPTIONS[] = {
- { "help", no_argument, 0, CMD_HELP },
- { "version", no_argument, 0, CMD_VERSION },
+ { "help", no_argument, 0, CMD_HELP },
+ { "version", no_argument, 0, CMD_VERSION },
+ { "xid", required_argument, 0, 'c' },
{ 0,0,0,0 }
};
struct Arguments
{
{ 0,0,0,0 }
};
struct Arguments
{
- xid_t
ctx
;
+ xid_t
xid
;
int sig;
};
int sig;
};
@@
-65,19
+67,13
@@
static char const * const SIGNALS[] = {
0,
};
0,
};
-inline static void UNUSED
-writeStr(int fd, char const *cmd)
-{
- (void)write(fd, cmd, strlen(cmd));
-}
-
static void
showHelp(int fd, char const *cmd, int res)
{
WRITE_MSG(fd, "Usage: ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
static void
showHelp(int fd, char const *cmd, int res)
{
WRITE_MSG(fd, "Usage: ");
WRITE_STR(fd, cmd);
WRITE_MSG(fd,
- " [-
c <ctx
>] [-s <signal>] [--] <pid>*\n"
+ " [-
-xid|-c <xid
>] [-s <signal>] [--] <pid>*\n"
"Please report bugs to " PACKAGE_BUGREPORT "\n");
exit(res);
}
"Please report bugs to " PACKAGE_BUGREPORT "\n");
exit(res);
}
@@
-115,14
+111,14
@@
str2sig(char const *str)
#if defined(VC_ENABLE_API_LEGACY)
inline static ALWAYSINLINE int
#if defined(VC_ENABLE_API_LEGACY)
inline static ALWAYSINLINE int
-kill_wrapper_legacy(xid_t
ctx, char const *proc, int
sig)
+kill_wrapper_legacy(xid_t
UNUSED xid, char const *proc, int UNUSED
sig)
{
{
- pid_t pid
= fork()
;
- if (pid==-1) {
-
perror("fork()"
);
-
exit(1
);
- }
-
else
if (pid==0) {
+ pid_t pid;
+
+
signal(SIGCHLD, SIG_DFL
);
+
pid = Efork(
);
+
+ if (pid==0) {
int status;
int res;
while ((res=wait4(pid, &status, 0,0))==-1 &&
int status;
int res;
while ((res=wait4(pid, &status, 0,0))==-1 &&
@@
-132,21
+128,21
@@
kill_wrapper_legacy(xid_t ctx, char const *proc, int sig)
}
execl(LEGACYDIR "/vkill", "legacy/vkill", proc, (void *)(0));
}
execl(LEGACYDIR "/vkill", "legacy/vkill", proc, (void *)(0));
- perror("execl()");
+ perror("
vkill:
execl()");
exit(1);
}
static int
exit(1);
}
static int
-kill_wrapper(xid_t
ctx
, char const *pid, int sig)
+kill_wrapper(xid_t
xid
, char const *pid, int sig)
{
{
- //printf("kill_wrapper(%u, %s, %i)\n",
ctx
, pid, sig);
- if (vc_ctx_kill(
ctx
,atoi(pid),sig)==-1) {
+ //printf("kill_wrapper(%u, %s, %i)\n",
xid
, pid, sig);
+ if (vc_ctx_kill(
xid
,atoi(pid),sig)==-1) {
int err = errno;
if (vc_get_version(VC_CAT_COMPAT)==-1)
int err = errno;
if (vc_get_version(VC_CAT_COMPAT)==-1)
- return kill_wrapper_legacy(
ctx
, pid, sig);
+ return kill_wrapper_legacy(
xid
, pid, sig);
else {
errno = err;
else {
errno = err;
- perror("vc_ctx_kill()");
+ perror("v
kill: v
c_ctx_kill()");
return 1;
}
}
return 1;
}
}
@@
-155,10
+151,10
@@
kill_wrapper(xid_t ctx, char const *pid, int sig)
}
#else // VC_ENABLE_API_LEGACY
inline static int
}
#else // VC_ENABLE_API_LEGACY
inline static int
-kill_wrapper(xid_t
ctx
, char const *pid, int sig)
+kill_wrapper(xid_t
xid
, char const *pid, int sig)
{
{
- if (vc_ctx_kill(
ctx
,atoi(pid),sig)==-1) {
- perror("vc_ctx_kill()");
+ if (vc_ctx_kill(
xid
,atoi(pid),sig)==-1) {
+ perror("v
kill: v
c_ctx_kill()");
return 1;
}
return 0;
return 1;
}
return 0;
@@
-170,7
+166,7
@@
int main(int argc, char *argv[])
{
int fail = 0;
struct Arguments args = {
{
int fail = 0;
struct Arguments args = {
- .
ctx
= VC_NOCTX,
+ .
xid
= VC_NOCTX,
.sig = SIGTERM,
};
.sig = SIGTERM,
};
@@
-181,8
+177,8
@@
int main(int argc, char *argv[])
switch (c) {
case CMD_HELP : showHelp(1, argv[0], 0);
case CMD_VERSION : showVersion();
switch (c) {
case CMD_HELP : showHelp(1, argv[0], 0);
case CMD_VERSION : showVersion();
- case 'c' : args.
ctx = atoi(optarg);
break;
- case 's' : args.sig = str2sig(optarg); break;
+ case 'c' : args.
xid = Evc_xidopt2xid(optarg,true);
break;
+ case 's' : args.sig = str2sig(optarg);
break;
default :
WRITE_MSG(2, "Try '");
WRITE_STR(2, argv[0]);
default :
WRITE_MSG(2, "Try '");
WRITE_STR(2, argv[0]);
@@
-197,15
+193,15
@@
int main(int argc, char *argv[])
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
- if (args.
ctx
==VC_NOCTX && optind==argc) {
+ if (args.
xid
==VC_NOCTX && optind==argc) {
WRITE_MSG(2, "No pid specified\n");
return EXIT_FAILURE;
}
if (optind==argc)
WRITE_MSG(2, "No pid specified\n");
return EXIT_FAILURE;
}
if (optind==argc)
- fail += kill_wrapper(args.
ctx
, "0", args.sig);
+ fail += kill_wrapper(args.
xid
, "0", args.sig);
else for (;optind<argc;++optind)
else for (;optind<argc;++optind)
- fail += kill_wrapper(args.
ctx
, argv[optind], args.sig);
+ fail += kill_wrapper(args.
xid
, argv[optind], args.sig);
return fail==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
return fail==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}