X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fvkill.c;h=57077faa209b3505e48c7706506ff7a84ac16035;hb=ec4370f7ebd7fb0ce7f002f5bf2c74f03acd3ec1;hp=02f386a5cc56518d7835bf9f42660a4656367fa2;hpb=9234e6a7cb48373edec38284ba54a819037b79b2;p=util-vserver.git diff --git a/src/vkill.c b/src/vkill.c index 02f386a..57077fa 100644 --- a/src/vkill.c +++ b/src/vkill.c @@ -1,4 +1,4 @@ -// $Id: vkill.c,v 1.8 2004/08/19 14:30:50 ensc Exp $ --*- c -*-- +// $Id: vkill.c 2491 2007-02-05 20:59:03Z dhozac $ --*- c -*-- // Copyright (C) 2003 Enrico Scholz // @@ -21,9 +21,10 @@ #endif #include "vserver.h" -#include "linuxvirtual.h" #include "util.h" +#include "lib/virtual.h" + #include #include #include @@ -151,9 +152,21 @@ kill_wrapper(xid_t xid, char const *pid, int sig) } #else // VC_ENABLE_API_LEGACY inline static int -kill_wrapper(xid_t xid, char const *pid, int sig) +kill_wrapper(xid_t xid, char const *pid_s, int sig) { - if (vc_ctx_kill(xid,atoi(pid),sig)==-1) { + pid_t pid; + long tmp; + + if (!isNumber(pid_s, &tmp, true)) { + WRITE_MSG(2, "vkill: '"); + WRITE_STR(2, pid_s); + WRITE_MSG(2, "' is not a number\n"); + } + pid = (pid_t) tmp; + + if (xid==VC_NOCTX) + xid = vc_get_task_xid(pid); + if (vc_ctx_kill(xid,pid,sig)==-1) { perror("vkill: vc_ctx_kill()"); return 1; } @@ -182,7 +195,7 @@ int main(int argc, char *argv[]) default : WRITE_MSG(2, "Try '"); WRITE_STR(2, argv[0]); - WRITE_MSG(2, " --help\" for more information.\n"); + WRITE_MSG(2, " --help' for more information.\n"); return EXIT_FAILURE; break; }