Changeset 2739
- Timestamp:
- 07/14/08 15:12:25 (4 months ago)
- Files:
-
- trunk/lib/exitlikeprocess.c (moved) (moved from trunk/lib_internal/util-exitlikeprocess.c) (4 diffs)
- trunk/lib/vserver.h (modified) (1 diff)
- trunk/lib_internal/Makefile-files (modified) (2 diffs)
- trunk/lib_internal/util-exitlikeprocess.h (deleted)
- trunk/lib_internal/util.h (modified) (1 diff)
- trunk/src/context-sync.hc (modified) (1 diff)
- trunk/src/vnamespace.c (modified) (3 diffs)
- trunk/src/vps.c (modified) (1 diff)
- trunk/src/vspace.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/exitlikeprocess.c
r1954 r2739 21 21 #endif 22 22 23 #include "util.h"24 #include <lib/internal.h>25 26 23 #include <stdlib.h> 27 24 #include <sys/types.h> … … 32 29 #include <sys/resource.h> 33 30 #include <stdio.h> 31 #include <errno.h> 32 33 #include "vserver.h" 34 35 static int pid; 36 static void 37 signalHandler(int signum) 38 { 39 xid_t xid = vc_get_task_xid(pid); 40 if (xid) 41 vc_ctx_kill(xid, pid, signum); 42 else 43 kill(pid, signum); 44 } 34 45 35 46 void 36 exitLikeProcess(int pid, char const *cmd, int ret)47 vc_exitLikeProcess(int p, int ret) 37 48 { 38 int status; 39 49 int status, i; 50 51 pid = p; 52 53 for (i = 0; i < 32; i++) 54 signal(i, signalHandler); 55 56 retry: 40 57 if (wait4(pid, &status, 0,0)==-1) { 41 58 if (errno==EINTR) 59 goto retry; 42 60 perror("wait()"); 43 61 exit(ret); … … 50 68 struct rlimit lim = { 0,0 }; 51 69 52 if (cmd) {53 char buf[sizeof(int)*3 + 2];54 size_t l = utilvserver_fmt_uint(buf, pid);55 56 WRITE_MSG(2, "command '");57 WRITE_STR(2, cmd);58 WRITE_MSG(2, "' (pid ");59 Vwrite (2, buf, l);60 WRITE_MSG(2, ") exited with signal ");61 l = utilvserver_fmt_uint(buf, WTERMSIG(status));62 Vwrite (2, buf, l);63 WRITE_MSG(2, "; following it...\n");64 }65 66 70 // prevent coredumps which might override the real ones 67 71 setrlimit(RLIMIT_CORE, &lim); … … 70 74 exit(1); 71 75 } 72 else { 73 char buf[sizeof(int)*3 + 2]; 74 size_t l = utilvserver_fmt_uint(buf, WTERMSIG(status)); 75 76 WRITE_MSG(2, "Unexpected status "); 77 Vwrite (2, buf, l); 78 WRITE_MSG(2, " from '"); 79 if (cmd) { 80 WRITE_STR(2, cmd); 81 WRITE_MSG(2, " (pid "); 82 } 83 l = utilvserver_fmt_uint(buf, pid); 84 Vwrite (2, buf, l); 85 if (cmd) WRITE_MSG(2, ")\n"); 86 else WRITE_MSG(2, "\n"); 87 76 else 88 77 exit(ret); 89 }90 78 } trunk/lib/vserver.h
r2736 r2739 1050 1050 int vc_compareVserverById(char const *lhs, vcCfgStyle lhs_style, 1051 1051 char const *rhs, vcCfgStyle rhs_style); 1052 1053 void vc_exitLikeProcess(int pid, int ret) VC_ATTR_NORETURN; 1052 1054 1053 1055 #define vcSKEL_INTERFACES 1u trunk/lib_internal/Makefile-files
r2685 r2739 72 72 lib_internal/util-dimof.h \ 73 73 lib_internal/util-dotfile.h \ 74 lib_internal/util-exitlikeprocess.h \75 74 lib_internal/util-io.h \ 76 75 lib_internal/util-lockfile.h \ … … 100 99 lib_internal/unify-isiunlinkable.c \ 101 100 lib_internal/util-canonify.c \ 102 lib_internal/util-exitlikeprocess.c \103 101 lib_internal/util-isnumber.hc \ 104 102 lib_internal/util-isnumber.c \ trunk/lib_internal/util.h
r2569 r2739 26 26 #include "util-dimof.h" 27 27 #include "util-dotfile.h" 28 #include "util-exitlikeprocess.h"29 28 #include "util-io.h" 30 29 #include "util-lockfile.h" trunk/src/context-sync.hc
r2015 r2739 84 84 Eclose(p[1][1]); 85 85 l = Eread(p[1][0], &c, 1); 86 if (l!=1) exitLikeProcess(pid,0, wrapper_exit_code);86 if (l!=1) vc_exitLikeProcess(pid, wrapper_exit_code); 87 87 l = Eread(p[1][0], &c, 1); 88 if (l!=0) exitLikeProcess(pid,0, wrapper_exit_code);88 if (l!=0) vc_exitLikeProcess(pid, wrapper_exit_code); 89 89 } trunk/src/vnamespace.c
r2693 r2739 89 89 90 90 static void 91 newNamespace( char const *cmd)91 newNamespace(void) 92 92 { 93 93 pid_t pid; … … 108 108 break; 109 109 default : 110 exitLikeProcess(pid, cmd, wrapper_exit_code);110 vc_exitLikeProcess(pid, wrapper_exit_code); 111 111 } 112 112 } … … 182 182 WRITE_MSG(2, "No command specified; try '--help' for more information\n"); 183 183 else { 184 if (do_new) newNamespace( argv[optind]);184 if (do_new) newNamespace(); 185 185 else if (do_set) setNamespace(VC_SAMECTX, CLONE_NEWNS|CLONE_FS); 186 186 else if (do_cleanup) cleanupNamespace(); trunk/src/vps.c
r2396 r2739 268 268 269 269 processOutput(data, len); 270 exitLikeProcess(pid, "ps", wrapper_exit_code);271 } 270 vc_exitLikeProcess(pid, wrapper_exit_code); 271 } trunk/src/vspace.c
r2713 r2739 107 107 108 108 static void 109 newSpaces(uint_least64_t mask , const char *cmd)109 newSpaces(uint_least64_t mask) 110 110 { 111 111 pid_t pid; … … 132 132 break; 133 133 default : 134 exitLikeProcess(pid, cmd, wrapper_exit_code);134 vc_exitLikeProcess(pid, wrapper_exit_code); 135 135 } 136 136 } … … 214 214 WRITE_MSG(2, "No command specified; try '--help' for more information\n"); 215 215 else { 216 if (do_new) newSpaces(mask , argv[optind]);216 if (do_new) newSpaces(mask); 217 217 else if (do_set) setSpaces(VC_SAMECTX, mask); 218 218 else if (do_enter) enterSpaces(xid, mask);
