use new exitLikeProcess() interface
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sat, 8 May 2004 01:38:13 +0000 (01:38 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sat, 8 May 2004 01:38:13 +0000 (01:38 +0000)
better error-handling

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1552 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/src/vps.c

index ead995d..036ea12 100644 (file)
@@ -76,14 +76,21 @@ showVersion()
 static size_t
 writeContextInfo(xid_t ctx, char const *name)
 {
-  char         buf[sizeof(ctx)*3+1];
-  size_t       l   = utilvserver_fmt_ulong(buf, ctx);
   size_t       l1  = name==0 ? 0 : strlen(name);
   size_t       res = CTXNR_WIDTH + 1;
+  
+  if (ctx==VC_NOCTX) {
+    if (3<CTXNR_WIDTH) write(1, CONTEXT_PLACE, CTXNR_WIDTH-3);
+    write(1, "ERR ", 4);
+  }
+  else {
+    char       buf[sizeof(ctx)*3+1];
+    size_t     l = utilvserver_fmt_ulong(buf, ctx);
 
-  if (l<CTXNR_WIDTH) write(1, CONTEXT_PLACE, CTXNR_WIDTH-l);
-  write(1, buf, l);
-  write(1, " ", 1);
+    if (l<CTXNR_WIDTH) write(1, CONTEXT_PLACE, CTXNR_WIDTH-l);
+    write(1, buf, l);
+    write(1, " ", 1);
+  }
 
   if (l1!=0) {
     assert(name!=0);
@@ -251,7 +258,7 @@ int main(int argc, char *argv[])
   
   processOutput(data, len);
 
-  exitLikeProcess(pid);
+  exitLikeProcess(pid, "ps");
   perror("exitLikeProcess()");
   return wrapper_exit_code;
 }