WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] Log when fork/exec()ed programs fail for debugging

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] Log when fork/exec()ed programs fail for debugging
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Tue, 16 Mar 2010 20:55:25 +0000
Delivery-date: Tue, 16 Mar 2010 13:46:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1268772876 0
# Node ID 194044dccbca88d5b1de83f91c2394f64205ea53
# Parent  b0519bd2911ded9c7dda1fd9b8b8962515c8b7f0
CA-38120: if we fork/exec a process and it doesn't exit with 0 (ie non-zero 
exit or signal of some kind) then log a message to syslog containing the pid, 
truncated cmdline and exit status.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r b0519bd2911d -r 194044dccbca forking_executioner/child.ml
--- a/forking_executioner/child.ml      Mon Feb 15 17:35:01 2010 +0000
+++ b/forking_executioner/child.ml      Tue Mar 16 20:54:36 2010 +0000
@@ -143,10 +143,25 @@
 
       List.iter (fun fd -> Unix.close fd) fds;
       let (pid,status) = Unix.waitpid [] result in
+         
+         let log_failure reason code = 
+               (* The commandline might be too long to clip it *)
+               let cmdline = String.concat " " args in
+               let limit = 80 - 3 in
+               let cmdline' = if String.length cmdline > limit then String.sub 
cmdline 0 limit ^ "..." else cmdline in
+               Syslog.log Syslog.Syslog Syslog.Err (Printf.sprintf "%d (%s) %s 
%d" result cmdline' reason code) in
+
       let pr = match status with
-       | Unix.WEXITED n -> Fe.WEXITED n
-       | Unix.WSIGNALED n -> Fe.WSIGNALED n 
-       | Unix.WSTOPPED n -> Fe.WSTOPPED n
+               | Unix.WEXITED 0 -> Fe.WEXITED 0
+               | Unix.WEXITED n -> 
+                         log_failure "exitted with code" n;
+                         Fe.WEXITED n
+               | Unix.WSIGNALED n -> 
+                         log_failure "exitted with signal" n;
+                         Fe.WSIGNALED n 
+               | Unix.WSTOPPED n -> 
+                         log_failure "stopped with signal" n;
+                         Fe.WSTOPPED n
       in
       let result = Fe.Finished (pr) in
       Fecomms.write_raw_rpc comms_sock result;
1 file changed, 18 insertions(+), 3 deletions(-)
forking_executioner/child.ml |   21 ++++++++++++++++++---


Attachment: xen-api-libs.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] Log when fork/exec()ed programs fail for debugging, David Scott <=