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 <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
Brad King 2017-02-20 19:48:25 -05:00 committed by Ben Noordhuis
parent 6c2fe3d946
commit 470b0258b0
4 changed files with 48 additions and 21 deletions

View File

@ -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

42
src/unix/no-proctitle.c Normal file
View File

@ -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 <errno.h>
#include <stddef.h>
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;
}

View File

@ -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;

5
uv.gyp
View File

@ -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',