ia64/xen-unstable

changeset 15697:f343d3c16dcc

xenstore: Do not assign to stdout/stderr/stdin - they are not
implemented as variables on all systems.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Aug 01 19:17:08 2007 +0100 (2007-08-01)
parents 88bb0d305308
children 07364f8574b8
files tools/xenstore/utils.c tools/xenstore/utils.h tools/xenstore/xenstored_core.c
line diff
     1.1 --- a/tools/xenstore/utils.c	Wed Aug 01 15:47:54 2007 +0100
     1.2 +++ b/tools/xenstore/utils.c	Wed Aug 01 19:17:08 2007 +0100
     1.3 @@ -10,19 +10,18 @@
     1.4  #include <signal.h>
     1.5  #include "utils.h"
     1.6  
     1.7 -void xprintf(const char *fmt, ...)
     1.8 +static void default_xprintf(const char *fmt, ...)
     1.9  {
    1.10  	va_list args;
    1.11  
    1.12 -	if (!stderr)
    1.13 -		return; /* could trace()? */
    1.14 -
    1.15  	va_start(args, fmt);
    1.16  	vfprintf(stderr, fmt, args);
    1.17  	va_end(args);
    1.18  	fflush(stderr);
    1.19  }
    1.20  
    1.21 +void (*xprintf)(const char *fmt, ...) = default_xprintf;
    1.22 +
    1.23  void barf(const char *fmt, ...)
    1.24  {
    1.25  	char *str;
     2.1 --- a/tools/xenstore/utils.h	Wed Aug 01 15:47:54 2007 +0100
     2.2 +++ b/tools/xenstore/utils.h	Wed Aug 01 19:17:08 2007 +0100
     2.3 @@ -24,7 +24,7 @@ static inline bool strends(const char *a
     2.4  void barf(const char *fmt, ...) __attribute__((noreturn));
     2.5  void barf_perror(const char *fmt, ...) __attribute__((noreturn));
     2.6  
     2.7 -void xprintf(const char *fmt, ...);
     2.8 +void (*xprintf)(const char *fmt, ...);
     2.9  
    2.10  #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
    2.11  
     3.1 --- a/tools/xenstore/xenstored_core.c	Wed Aug 01 15:47:54 2007 +0100
     3.2 +++ b/tools/xenstore/xenstored_core.c	Wed Aug 01 19:17:08 2007 +0100
     3.3 @@ -1883,11 +1883,7 @@ int main(int argc, char *argv[])
     3.4  		close(STDIN_FILENO);
     3.5  		close(STDOUT_FILENO);
     3.6  		close(STDERR_FILENO);
     3.7 -
     3.8 -		/* Get ourselves a nice xenstored crash if these are used. */
     3.9 -		stdin = NULL;
    3.10 -		stdout = NULL;
    3.11 -		stderr = NULL;
    3.12 +		xprintf = trace; /* xprintf() must not use stderr */
    3.13  	}
    3.14  
    3.15  	signal(SIGHUP, trigger_reopen_log);