From 470b0258b0fc9e6249e289b0daae53e8418847ff Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 20 Feb 2017 19:48:25 -0500 Subject: [PATCH] unix: factor out reusable no-proctitle impl On SunOS we implement no support for proctitle. Other platforms may not support proctitle either, so provide a dedicated source file to use in this case. PR-URL: https://github.com/libuv/libuv/pull/1312 Reviewed-By: Ben Noordhuis Reviewed-By: Santiago Gimeno --- Makefile.am | 3 ++- src/unix/no-proctitle.c | 42 +++++++++++++++++++++++++++++++++++++++++ src/unix/sunos.c | 19 ------------------- uv.gyp | 5 ++++- 4 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 src/unix/no-proctitle.c diff --git a/Makefile.am b/Makefile.am index e70c7cfc..cbabbab4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -402,7 +402,8 @@ endif if SUNOS include_HEADERS += include/uv-sunos.h libuv_la_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -libuv_la_SOURCES += src/unix/sunos.c +libuv_la_SOURCES += src/unix/no-proctitle.c \ + src/unix/sunos.c endif if OS390 diff --git a/src/unix/no-proctitle.c b/src/unix/no-proctitle.c new file mode 100644 index 00000000..a5c19fbf --- /dev/null +++ b/src/unix/no-proctitle.c @@ -0,0 +1,42 @@ +/* Copyright libuv project contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "internal.h" + +#include +#include + +char** uv_setup_args(int argc, char** argv) { + return argv; +} + +int uv_set_process_title(const char* title) { + return 0; +} + +int uv_get_process_title(char* buffer, size_t size) { + if (buffer == NULL || size == 0) + return -EINVAL; + + buffer[0] = '\0'; + return 0; +} diff --git a/src/unix/sunos.c b/src/unix/sunos.c index c34b870e..2dc02ae4 100644 --- a/src/unix/sunos.c +++ b/src/unix/sunos.c @@ -545,25 +545,6 @@ void uv__fs_event_close(uv_fs_event_t* handle) { #endif /* defined(PORT_SOURCE_FILE) */ -char** uv_setup_args(int argc, char** argv) { - return argv; -} - - -int uv_set_process_title(const char* title) { - return 0; -} - - -int uv_get_process_title(char* buffer, size_t size) { - if (buffer == NULL || size == 0) - return -EINVAL; - - buffer[0] = '\0'; - return 0; -} - - int uv_resident_set_memory(size_t* rss) { psinfo_t psinfo; int err; diff --git a/uv.gyp b/uv.gyp index eac8677f..77312200 100644 --- a/uv.gyp +++ b/uv.gyp @@ -257,7 +257,10 @@ }, }], [ 'OS=="solaris"', { - 'sources': [ 'src/unix/sunos.c' ], + 'sources': [ + 'src/unix/no-proctitle.c', + 'src/unix/sunos.c', + ], 'defines': [ '__EXTENSIONS__', '_XOPEN_SOURCE=500',