X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvkill.c;h=5f5ace338e10c12640d0b062f0da0a8a292df568;hb=989f6cc00a65b6c06f1453f50abc442a28dad714;hp=11189e6e5983582cabde09b158a4eb776bc0cc11;hpb=9c78378bebc1a9f3d400f422df8ede9efea57dea;p=util-vserver.git diff --git a/src/vkill.c b/src/vkill.c index 11189e6..5f5ace3 100644 --- a/src/vkill.c +++ b/src/vkill.c @@ -136,6 +136,9 @@ kill_wrapper_legacy(xid_t UNUSED xid, char const *proc, int UNUSED sig) static int kill_wrapper(xid_t xid, char const *pid, int sig) { + if (xid==VC_NOCTX) + xid = vc_get_task_xid(pid); + //printf("kill_wrapper(%u, %s, %i)\n", xid, pid, sig); if (vc_ctx_kill(xid,atoi(pid),sig)==-1) { int err = errno; @@ -152,9 +155,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; } @@ -183,7 +198,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; }