Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
Added 'process' feature for unix systems. (#121)
Browse files Browse the repository at this point in the history
It is disabled by default. 'TUV_FEATURE_PROCESS' cmake define must be set to enable.
'TUV_FEATURE_PROCESS' implicitly enables 'TUV_FEATURE_PIPE' and 'TUV_FEATURE_SIGNAL'
features.

libtuv-DCO-1.0-Signed-off-by: László Langó [email protected]
  • Loading branch information
LaszloLango authored and yichoi committed Aug 13, 2018
1 parent 9f32c3d commit 05e739c
Show file tree
Hide file tree
Showing 9 changed files with 3,166 additions and 27 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ CMAKE_DEFINES := \
-DBUILDTESTER=${TUV_BUILDTESTER} \
-DBUILD_HOST_HELPER=${TUV_BUILDHOSTHELPER} \
-DCREATE_SHARED_LIB=${TUV_CREATE_SHARED_LIB} \
-DTUV_FEATURE_SIGNAL=ON \
-DTUV_FEATURE_PIPE=ON
-DTUV_FEATURE_PROCESS=ON

ifneq ($(TUV_BOARD),unknown)
CMAKE_DEFINES += -DTARGET_BOARD=${TUV_BOARD}
Expand Down
12 changes: 12 additions & 0 deletions cmake/option/option_unix_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ set(TEST_UNITFILES
"${TEST_ROOT}/test_async.c"
)

# { TUV_CHANGES@20180803:
# Made signal build time configurable }
if(TUV_FEATURE_PROCESS)
set(TUV_FEATURE_PIPE ON)
set(TUV_FEATURE_SIGNAL ON)
set(FLAGS_COMMON "${FLAGS_COMMON}" "-DTUV_FEATURE_PROCESS=1")
set(TEST_UNITFILES "${TEST_UNITFILES}"
"${TEST_ROOT}/test_ipc.c"
"${TEST_ROOT}/test_spawn.c")
endif()


# { TUV_CHANGES@20180724:
# Made pipe build time configurable }
if(TUV_FEATURE_PIPE)
Expand Down
10 changes: 9 additions & 1 deletion src/unix/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
uv__timer_close((uv_timer_t*)handle);
break;

// { TUV_CHANGES@20180803:
// Made signal build time configurable }
#if TUV_FEATURE_PROCESS
case UV_PROCESS:
uv__process_close((uv_process_t*)handle);
break;
#endif

case UV_POLL:
uv__poll_close((uv_poll_t*)handle);
break;
Expand Down Expand Up @@ -209,7 +217,7 @@ static void uv__finish_close(uv_handle_t* handle) {
case UV_IDLE:
case UV_ASYNC:
case UV_TIMER:
// case UV_PROCESS:
case UV_PROCESS:
// case UV_FS_EVENT:
// case UV_FS_POLL:
case UV_POLL:
Expand Down
23 changes: 23 additions & 0 deletions src/unix/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,26 @@ uint64_t uv__hrtime(uv_clocktype_t type) {

return t.tv_sec * (uint64_t) 1e9 + t.tv_nsec;
}

// { TUV_CHANGES@20180803:
// Made signal build time configurable }
#if TUV_FEATURE_PROCESS
int uv_exepath(char* buffer, size_t* size) {
ssize_t n;

if (buffer == NULL || size == NULL || *size == 0)
return -EINVAL;

n = *size - 1;
if (n > 0)
n = readlink("/proc/self/exe", buffer, n);

if (n == -1)
return -errno;

buffer[n] = '\0';
*size = n;

return 0;
}
#endif /* TUV_FEATURE_PROCESS */
Loading

0 comments on commit 05e739c

Please sign in to comment.