diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2014-12-07 19:04:11 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2014-12-07 19:04:11 +0100 |
commit | c1ee4a252d82ff8ef4bf0845b4c2f21d2b4ec000 (patch) | |
tree | 4576102b682364a423870352e2e4e7d7b98c90c9 /src | |
parent | 645bd551dcfb609ce4b57a205bbf1c3e129d4ef3 (diff) | |
download | biruda-c1ee4a252d82ff8ef4bf0845b4c2f21d2b4ec000.tar.gz biruda-c1ee4a252d82ff8ef4bf0845b4c2f21d2b4ec000.tar.bz2 |
passing pid as string in a message, added portable PRIx macro for GPid
Diffstat (limited to 'src')
-rw-r--r-- | src/port.h | 6 | ||||
-rw-r--r-- | src/worker.c | 8 |
2 files changed, 12 insertions, 2 deletions
@@ -37,4 +37,10 @@ typedef unsigned char _Bool; #define PORT_DIR_SEPARATOR '/' #endif +#ifdef _WIN32 +#define PRIgid "%p" +#else +#define PRIgid "%d" +#endif + #endif diff --git a/src/worker.c b/src/worker.c index 3bebd60..bcf01f3 100644 --- a/src/worker.c +++ b/src/worker.c @@ -116,7 +116,9 @@ static char *create_worker_termination_answer( const char *name, GPid pid ) json_object *name_obj = json_object_new_string( name ); json_object_object_add( obj, "worker", name_obj ); - json_object *pid_obj = json_object_new_int( pid ); + char pid_str[64]; + snprintf( pid_str, sizeof( pid_str ), PRIgid, pid ); + json_object *pid_obj = json_object_new_string( pid_str ); json_object_object_add( obj, "pid", pid_obj ); time_t ts; @@ -146,7 +148,9 @@ static char *create_worker_created_answer( const char *name, GPid pid ) json_object *name_obj = json_object_new_string( name ); json_object_object_add( obj, "worker", name_obj ); - json_object *pid_obj = json_object_new_int( pid ); + char pid_str[64]; + snprintf( pid_str, sizeof( pid_str ), PRIgid, pid ); + json_object *pid_obj = json_object_new_string( pid_str ); json_object_object_add( obj, "pid", pid_obj ); time_t ts; |