diff options
author | Pawel Baldysiak <pawel.baldysiak@intel.com> | 2015-02-11 22:25:03 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2015-02-12 02:11:01 +0100 |
commit | d56dd607ba433d9334f0fb4114fe081742ae4361 (patch) | |
tree | 80fa1ea9cdc500c5316b6b58998e4de37694272c /xmalloc.c | |
parent | Monitor: fix for regression with container devices (diff) | |
download | mdadm-d56dd607ba433d9334f0fb4114fe081742ae4361.tar.xz mdadm-d56dd607ba433d9334f0fb4114fe081742ae4361.zip |
Change way of printing name of a process
Sometimes mdadm prints messages with wrong name "mdmon",
and vice versa.
This patch solves this problem by changing method of determining
process name.
Now "Name" will be set in const at start of a program,
previously was hardcoded as #define.
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'xmalloc.c')
-rw-r--r-- | xmalloc.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -37,7 +37,8 @@ void *xmalloc(size_t len) char *msg; if (rv) return rv; - msg = Name ": memory allocation failure - aborting\n"; + msg = ": memory allocation failure - aborting\n"; + write(2, Name, strlen(Name)); exit(4+!!write(2, msg, strlen(msg))); } @@ -47,7 +48,8 @@ void *xrealloc(void *ptr, size_t len) char *msg; if (rv) return rv; - msg = Name ": memory allocation failure - aborting\n"; + msg = ": memory allocation failure - aborting\n"; + write(2, Name, strlen(Name)); exit(4+!!write(2, msg, strlen(msg))); } @@ -57,7 +59,8 @@ void *xcalloc(size_t num, size_t size) char *msg; if (rv) return rv; - msg = Name ": memory allocation failure - aborting\n"; + msg = ": memory allocation failure - aborting\n"; + write(2, Name, strlen(Name)); exit(4+!!write(2, msg, strlen(msg))); } @@ -67,6 +70,7 @@ char *xstrdup(const char *str) char *msg; if (rv) return rv; - msg = Name ": memory allocation failure - aborting\n"; + msg = ": memory allocation failure - aborting\n"; + write(2, Name, strlen(Name)); exit(4+!!write(2, msg, strlen(msg))); } |