noderb 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +25 -0
- data/ext/noderb_extension/extconf.rb +11 -0
- data/ext/noderb_extension/libuv/AUTHORS +11 -0
- data/ext/noderb_extension/libuv/LICENSE +48 -0
- data/ext/noderb_extension/libuv/Makefile +119 -0
- data/ext/noderb_extension/libuv/README +45 -0
- data/ext/noderb_extension/libuv/build/all.gyp +254 -0
- data/ext/noderb_extension/libuv/build/common.gypi +13 -0
- data/ext/noderb_extension/libuv/build/gyp_uv +43 -0
- data/ext/noderb_extension/libuv/config-mingw.mk +67 -0
- data/ext/noderb_extension/libuv/config-unix.mk +121 -0
- data/ext/noderb_extension/libuv/create-msvs-files.bat +14 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ANNOUNCE +482 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/BUGS +141 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Bmakefile +268 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/CONTRIBUTORS +140 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING +150 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING.LIB +504 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ChangeLog +5194 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/FAQ +451 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/GNUmakefile +593 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/MAINTAINERS +4 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Makefile +516 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/NEWS +1245 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile +24 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile.tests +260 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/PROGRESS +4 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README +601 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Borland +57 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.CV +3036 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.NONPORTABLE +783 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Watcom +62 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.WinCE +6 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/TODO +7 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/WinCE-PORT +222 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/attr.c +53 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/autostatic.c +69 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/barrier.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/build/all.gyp +207 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/builddmc.bat +9 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/cancel.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/cleanup.c +148 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/condvar.c +50 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/config.h +153 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/context.h +74 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/create.c +308 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/dll.c +92 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/errno.c +94 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/exit.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/fork.c +39 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/global.c +107 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/implement.h +944 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/misc.c +50 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/mutex.c +62 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/need_errno.h +145 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/nonportable.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/private.c +54 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.c +66 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsp +142 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsw +29 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.h +1368 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_destroy.c +79 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getdetachstate.c +86 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getinheritsched.c +51 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedparam.c +52 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedpolicy.c +61 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getscope.c +54 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstackaddr.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstacksize.c +100 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_init.c +117 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setdetachstate.c +91 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setinheritsched.c +57 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedparam.c +63 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedpolicy.c +55 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setscope.c +62 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstackaddr.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstacksize.c +110 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_destroy.c +103 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_init.c +69 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_wait.c +104 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_destroy.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_getpshared.c +95 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_init.c +85 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_setpshared.c +119 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cancel.c +189 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_destroy.c +253 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_init.c +167 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_signal.c +231 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_wait.c +567 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_destroy.c +86 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_getpshared.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_init.c +87 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_setpshared.c +117 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_delay_np.c +172 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_detach.c +136 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_equal.c +76 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_exit.c +106 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getconcurrency.c +45 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getschedparam.c +75 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getspecific.c +87 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getunique_np.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getw32threadhandle_np.c +65 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_join.c +157 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_create.c +108 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_delete.c +125 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_kill.c +105 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_consistent.c +187 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_destroy.c +148 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_init.c +130 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_lock.c +269 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_timedlock.c +324 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_trylock.c +154 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_unlock.c +175 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_destroy.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getkind_np.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getpshared.c +95 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getrobust.c +113 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_gettype.c +56 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_init.c +86 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setkind_np.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setpshared.c +119 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setrobust.c +119 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_settype.c +143 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_num_processors_np.c +56 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_once.c +79 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_destroy.c +143 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_init.c +109 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_rdlock.c +102 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedrdlock.c +109 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedwrlock.c +139 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_tryrdlock.c +102 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_trywrlock.c +122 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_unlock.c +93 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_wrlock.c +133 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_destroy.c +84 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_getpshared.c +97 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_init.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_setpshared.c +120 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_self.c +141 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcancelstate.c +125 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcanceltype.c +126 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setconcurrency.c +53 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setschedparam.c +123 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setspecific.c +167 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_destroy.c +111 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_init.c +123 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_lock.c +80 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_trylock.c +77 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_unlock.c +71 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_testcancel.c +103 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_timechange_handler_np.c +108 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_win32_attach_detach_np.c +258 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_MCS_lock.c +278 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_callUserDestroyRoutines.c +232 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_calloc.c +56 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_cond_check_need_init.c +78 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_getprocessors.c +91 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_is_attr.c +47 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_mutex_check_need_init.c +92 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_new.c +94 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processInitialize.c +92 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processTerminate.c +105 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_relmillisecs.c +132 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_reuse.c +151 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_cancelwrwait.c +50 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_check_need_init.c +77 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_semwait.c +135 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_spinlock_check_need_init.c +78 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadDestroy.c +79 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadStart.c +357 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_throw.c +189 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_timespec.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocCreate.c +118 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocDestroy.c +114 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/rwlock.c +51 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.c +53 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.h +183 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_max.c +134 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_min.c +135 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_getscheduler.c +71 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_setscheduler.c +83 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_yield.c +71 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_close.c +58 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_destroy.c +144 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_getvalue.c +110 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_init.c +169 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_open.c +58 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post.c +128 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post_multiple.c +142 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_timedwait.c +238 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_trywait.c +117 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_unlink.c +58 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_wait.c +187 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.c +69 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.h +169 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/signal.c +179 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/spin.c +46 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/sync.c +43 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/tsd.c +44 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/version.rc +388 -0
- data/ext/noderb_extension/libuv/deps/pthread-win32/w32_CancelableWait.c +161 -0
- data/ext/noderb_extension/libuv/doc/desired-api.md +159 -0
- data/ext/noderb_extension/libuv/doc/iocp-links.html +574 -0
- data/ext/noderb_extension/libuv/include/ares.h +582 -0
- data/ext/noderb_extension/libuv/include/ares_version.h +24 -0
- data/ext/noderb_extension/libuv/include/eio.h +376 -0
- data/ext/noderb_extension/libuv/include/ev.h +835 -0
- data/ext/noderb_extension/libuv/include/ngx-queue.h +102 -0
- data/ext/noderb_extension/libuv/include/tree.h +762 -0
- data/ext/noderb_extension/libuv/include/uv-unix.h +138 -0
- data/ext/noderb_extension/libuv/include/uv-win.h +187 -0
- data/ext/noderb_extension/libuv/include/uv.h +635 -0
- data/ext/noderb_extension/libuv/src/ares/AUTHORS +37 -0
- data/ext/noderb_extension/libuv/src/ares/CHANGES +1198 -0
- data/ext/noderb_extension/libuv/src/ares/CMakeLists.txt +22 -0
- data/ext/noderb_extension/libuv/src/ares/NEWS +21 -0
- data/ext/noderb_extension/libuv/src/ares/README +60 -0
- data/ext/noderb_extension/libuv/src/ares/README.cares +13 -0
- data/ext/noderb_extension/libuv/src/ares/README.msvc +118 -0
- data/ext/noderb_extension/libuv/src/ares/README.node +21 -0
- data/ext/noderb_extension/libuv/src/ares/RELEASE-NOTES +25 -0
- data/ext/noderb_extension/libuv/src/ares/TODO +23 -0
- data/ext/noderb_extension/libuv/src/ares/ares__close_sockets.c +66 -0
- data/ext/noderb_extension/libuv/src/ares/ares__get_hostent.c +263 -0
- data/ext/noderb_extension/libuv/src/ares/ares__read_line.c +71 -0
- data/ext/noderb_extension/libuv/src/ares/ares__timeval.c +111 -0
- data/ext/noderb_extension/libuv/src/ares/ares_cancel.c +63 -0
- data/ext/noderb_extension/libuv/src/ares/ares_data.c +190 -0
- data/ext/noderb_extension/libuv/src/ares/ares_data.h +65 -0
- data/ext/noderb_extension/libuv/src/ares/ares_destroy.c +105 -0
- data/ext/noderb_extension/libuv/src/ares/ares_dns.h +90 -0
- data/ext/noderb_extension/libuv/src/ares/ares_expand_name.c +193 -0
- data/ext/noderb_extension/libuv/src/ares/ares_expand_string.c +75 -0
- data/ext/noderb_extension/libuv/src/ares/ares_fds.c +62 -0
- data/ext/noderb_extension/libuv/src/ares/ares_free_hostent.c +39 -0
- data/ext/noderb_extension/libuv/src/ares/ares_free_string.c +25 -0
- data/ext/noderb_extension/libuv/src/ares/ares_gethostbyaddr.c +292 -0
- data/ext/noderb_extension/libuv/src/ares/ares_gethostbyname.c +515 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getnameinfo.c +426 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getopt.c +122 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getopt.h +53 -0
- data/ext/noderb_extension/libuv/src/ares/ares_getsock.c +72 -0
- data/ext/noderb_extension/libuv/src/ares/ares_init.c +1665 -0
- data/ext/noderb_extension/libuv/src/ares/ares_ipv6.h +78 -0
- data/ext/noderb_extension/libuv/src/ares/ares_library_init.c +132 -0
- data/ext/noderb_extension/libuv/src/ares/ares_library_init.h +39 -0
- data/ext/noderb_extension/libuv/src/ares/ares_llist.c +86 -0
- data/ext/noderb_extension/libuv/src/ares/ares_llist.h +42 -0
- data/ext/noderb_extension/libuv/src/ares/ares_mkquery.c +195 -0
- data/ext/noderb_extension/libuv/src/ares/ares_nowarn.c +59 -0
- data/ext/noderb_extension/libuv/src/ares/ares_nowarn.h +24 -0
- data/ext/noderb_extension/libuv/src/ares/ares_options.c +253 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_a_reply.c +260 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_aaaa_reply.c +256 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_mx_reply.c +170 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_ns_reply.c +182 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_ptr_reply.c +208 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_srv_reply.c +179 -0
- data/ext/noderb_extension/libuv/src/ares/ares_parse_txt_reply.c +201 -0
- data/ext/noderb_extension/libuv/src/ares/ares_private.h +351 -0
- data/ext/noderb_extension/libuv/src/ares/ares_process.c +1296 -0
- data/ext/noderb_extension/libuv/src/ares/ares_query.c +183 -0
- data/ext/noderb_extension/libuv/src/ares/ares_rules.h +144 -0
- data/ext/noderb_extension/libuv/src/ares/ares_search.c +322 -0
- data/ext/noderb_extension/libuv/src/ares/ares_send.c +134 -0
- data/ext/noderb_extension/libuv/src/ares/ares_setup.h +191 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strcasecmp.c +66 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strcasecmp.h +30 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strdup.c +42 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strdup.h +26 -0
- data/ext/noderb_extension/libuv/src/ares/ares_strerror.c +56 -0
- data/ext/noderb_extension/libuv/src/ares/ares_timeout.c +80 -0
- data/ext/noderb_extension/libuv/src/ares/ares_version.c +11 -0
- data/ext/noderb_extension/libuv/src/ares/ares_writev.c +79 -0
- data/ext/noderb_extension/libuv/src/ares/ares_writev.h +36 -0
- data/ext/noderb_extension/libuv/src/ares/bitncmp.c +59 -0
- data/ext/noderb_extension/libuv/src/ares/bitncmp.h +26 -0
- data/ext/noderb_extension/libuv/src/ares/config_cygwin/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_darwin/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_freebsd/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_linux/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_openbsd/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_sunos/ares_config.h +510 -0
- data/ext/noderb_extension/libuv/src/ares/config_win32/ares_config.h +369 -0
- data/ext/noderb_extension/libuv/src/ares/get_ver.awk +35 -0
- data/ext/noderb_extension/libuv/src/ares/inet_net_pton.c +450 -0
- data/ext/noderb_extension/libuv/src/ares/inet_net_pton.h +31 -0
- data/ext/noderb_extension/libuv/src/ares/inet_ntop.c +232 -0
- data/ext/noderb_extension/libuv/src/ares/inet_ntop.h +27 -0
- data/ext/noderb_extension/libuv/src/ares/nameser.h +193 -0
- data/ext/noderb_extension/libuv/src/ares/setup_once.h +488 -0
- data/ext/noderb_extension/libuv/src/ares/windows_port.c +22 -0
- data/ext/noderb_extension/libuv/src/eio/Changes +63 -0
- data/ext/noderb_extension/libuv/src/eio/LICENSE +36 -0
- data/ext/noderb_extension/libuv/src/eio/Makefile.am +15 -0
- data/ext/noderb_extension/libuv/src/eio/aclocal.m4 +8957 -0
- data/ext/noderb_extension/libuv/src/eio/autogen.sh +3 -0
- data/ext/noderb_extension/libuv/src/eio/config.h.in +86 -0
- data/ext/noderb_extension/libuv/src/eio/config_cygwin.h +77 -0
- data/ext/noderb_extension/libuv/src/eio/config_darwin.h +137 -0
- data/ext/noderb_extension/libuv/src/eio/config_freebsd.h +78 -0
- data/ext/noderb_extension/libuv/src/eio/config_linux.h +101 -0
- data/ext/noderb_extension/libuv/src/eio/config_sunos.h +81 -0
- data/ext/noderb_extension/libuv/src/eio/configure.ac +22 -0
- data/ext/noderb_extension/libuv/src/eio/demo.c +194 -0
- data/ext/noderb_extension/libuv/src/eio/ecb.h +370 -0
- data/ext/noderb_extension/libuv/src/eio/eio.3 +3428 -0
- data/ext/noderb_extension/libuv/src/eio/eio.c +2562 -0
- data/ext/noderb_extension/libuv/src/eio/eio.pod +969 -0
- data/ext/noderb_extension/libuv/src/eio/libeio.m4 +195 -0
- data/ext/noderb_extension/libuv/src/eio/xthread.h +164 -0
- data/ext/noderb_extension/libuv/src/ev/Changes +388 -0
- data/ext/noderb_extension/libuv/src/ev/LICENSE +36 -0
- data/ext/noderb_extension/libuv/src/ev/Makefile.am +18 -0
- data/ext/noderb_extension/libuv/src/ev/Makefile.in +771 -0
- data/ext/noderb_extension/libuv/src/ev/README +58 -0
- data/ext/noderb_extension/libuv/src/ev/aclocal.m4 +8957 -0
- data/ext/noderb_extension/libuv/src/ev/autogen.sh +6 -0
- data/ext/noderb_extension/libuv/src/ev/config.guess +1526 -0
- data/ext/noderb_extension/libuv/src/ev/config.h.in +125 -0
- data/ext/noderb_extension/libuv/src/ev/config.sub +1658 -0
- data/ext/noderb_extension/libuv/src/ev/config_cygwin.h +123 -0
- data/ext/noderb_extension/libuv/src/ev/config_darwin.h +122 -0
- data/ext/noderb_extension/libuv/src/ev/config_freebsd.h +120 -0
- data/ext/noderb_extension/libuv/src/ev/config_linux.h +130 -0
- data/ext/noderb_extension/libuv/src/ev/config_sunos.h +122 -0
- data/ext/noderb_extension/libuv/src/ev/configure +13037 -0
- data/ext/noderb_extension/libuv/src/ev/configure.ac +18 -0
- data/ext/noderb_extension/libuv/src/ev/depcomp +630 -0
- data/ext/noderb_extension/libuv/src/ev/ev++.h +816 -0
- data/ext/noderb_extension/libuv/src/ev/ev.3 +5311 -0
- data/ext/noderb_extension/libuv/src/ev/ev.c +3913 -0
- data/ext/noderb_extension/libuv/src/ev/ev.pod +5243 -0
- data/ext/noderb_extension/libuv/src/ev/ev_epoll.c +266 -0
- data/ext/noderb_extension/libuv/src/ev/ev_kqueue.c +198 -0
- data/ext/noderb_extension/libuv/src/ev/ev_poll.c +148 -0
- data/ext/noderb_extension/libuv/src/ev/ev_port.c +179 -0
- data/ext/noderb_extension/libuv/src/ev/ev_select.c +310 -0
- data/ext/noderb_extension/libuv/src/ev/ev_vars.h +203 -0
- data/ext/noderb_extension/libuv/src/ev/ev_win32.c +153 -0
- data/ext/noderb_extension/libuv/src/ev/ev_wrap.h +196 -0
- data/ext/noderb_extension/libuv/src/ev/event.c +402 -0
- data/ext/noderb_extension/libuv/src/ev/event.h +170 -0
- data/ext/noderb_extension/libuv/src/ev/install-sh +294 -0
- data/ext/noderb_extension/libuv/src/ev/libev.m4 +39 -0
- data/ext/noderb_extension/libuv/src/ev/ltmain.sh +8413 -0
- data/ext/noderb_extension/libuv/src/ev/missing +336 -0
- data/ext/noderb_extension/libuv/src/ev/mkinstalldirs +111 -0
- data/ext/noderb_extension/libuv/src/uv-common.c +172 -0
- data/ext/noderb_extension/libuv/src/uv-common.h +53 -0
- data/ext/noderb_extension/libuv/src/uv-cygwin.c +52 -0
- data/ext/noderb_extension/libuv/src/uv-darwin.c +64 -0
- data/ext/noderb_extension/libuv/src/uv-eio.c +113 -0
- data/ext/noderb_extension/libuv/src/uv-eio.h +13 -0
- data/ext/noderb_extension/libuv/src/uv-freebsd.c +65 -0
- data/ext/noderb_extension/libuv/src/uv-linux.c +51 -0
- data/ext/noderb_extension/libuv/src/uv-sunos.c +60 -0
- data/ext/noderb_extension/libuv/src/uv-unix.c +2408 -0
- data/ext/noderb_extension/libuv/src/win/async.c +129 -0
- data/ext/noderb_extension/libuv/src/win/cares.c +304 -0
- data/ext/noderb_extension/libuv/src/win/core.c +155 -0
- data/ext/noderb_extension/libuv/src/win/error.c +140 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +341 -0
- data/ext/noderb_extension/libuv/src/win/handle.c +176 -0
- data/ext/noderb_extension/libuv/src/win/internal.h +237 -0
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +128 -0
- data/ext/noderb_extension/libuv/src/win/pipe.c +828 -0
- data/ext/noderb_extension/libuv/src/win/process.c +936 -0
- data/ext/noderb_extension/libuv/src/win/req.c +141 -0
- data/ext/noderb_extension/libuv/src/win/stdio.c +75 -0
- data/ext/noderb_extension/libuv/src/win/stream.c +149 -0
- data/ext/noderb_extension/libuv/src/win/tcp.c +895 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +269 -0
- data/ext/noderb_extension/libuv/src/win/util.c +82 -0
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +117 -0
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +90 -0
- data/ext/noderb_extension/libuv/test/benchmark-list.h +77 -0
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +210 -0
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +237 -0
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +459 -0
- data/ext/noderb_extension/libuv/test/benchmark-sizes.c +39 -0
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +154 -0
- data/ext/noderb_extension/libuv/test/dns-server.c +323 -0
- data/ext/noderb_extension/libuv/test/echo-server.c +299 -0
- data/ext/noderb_extension/libuv/test/run-benchmarks.c +64 -0
- data/ext/noderb_extension/libuv/test/run-tests.c +82 -0
- data/ext/noderb_extension/libuv/test/runner-unix.c +335 -0
- data/ext/noderb_extension/libuv/test/runner-unix.h +36 -0
- data/ext/noderb_extension/libuv/test/runner-win.c +343 -0
- data/ext/noderb_extension/libuv/test/runner-win.h +42 -0
- data/ext/noderb_extension/libuv/test/runner.c +311 -0
- data/ext/noderb_extension/libuv/test/runner.h +155 -0
- data/ext/noderb_extension/libuv/test/task.h +111 -0
- data/ext/noderb_extension/libuv/test/test-async.c +218 -0
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +205 -0
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +149 -0
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +198 -0
- data/ext/noderb_extension/libuv/test/test-fail-always.c +29 -0
- data/ext/noderb_extension/libuv/test/test-get-currentexe.c +53 -0
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +110 -0
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +192 -0
- data/ext/noderb_extension/libuv/test/test-getsockname.c +196 -0
- data/ext/noderb_extension/libuv/test/test-hrtime.c +51 -0
- data/ext/noderb_extension/libuv/test/test-idle.c +83 -0
- data/ext/noderb_extension/libuv/test/test-list.h +165 -0
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +361 -0
- data/ext/noderb_extension/libuv/test/test-pass-always.c +28 -0
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +256 -0
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +148 -0
- data/ext/noderb_extension/libuv/test/test-ref.c +91 -0
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +183 -0
- data/ext/noderb_extension/libuv/test/test-spawn.c +345 -0
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +204 -0
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +164 -0
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +198 -0
- data/ext/noderb_extension/libuv/test/test-timer-again.c +141 -0
- data/ext/noderb_extension/libuv/test/test-timer.c +134 -0
- data/ext/noderb_extension/noderb.c +340 -0
- data/ext/noderb_extension/noderb.h +2 -0
- data/lib/noderb/connection.rb +21 -0
- data/lib/noderb/process.rb +17 -0
- data/lib/noderb.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,936 @@
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19
|
+
* IN THE SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "uv.h"
|
23
|
+
#include "../uv-common.h"
|
24
|
+
#include "internal.h"
|
25
|
+
|
26
|
+
#include <stdio.h>
|
27
|
+
#include <assert.h>
|
28
|
+
#include <stdlib.h>
|
29
|
+
#include <windows.h>
|
30
|
+
|
31
|
+
#define UTF8_TO_UTF16(s, t) \
|
32
|
+
size = uv_utf8_to_utf16(s, NULL, 0) * sizeof(wchar_t); \
|
33
|
+
t = (wchar_t*)malloc(size); \
|
34
|
+
if (!t) { \
|
35
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); \
|
36
|
+
} \
|
37
|
+
if (!uv_utf8_to_utf16(s, t, size / sizeof(wchar_t))) { \
|
38
|
+
uv_set_sys_error(GetLastError()); \
|
39
|
+
err = -1; \
|
40
|
+
goto done; \
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
static const wchar_t DEFAULT_PATH_EXT[10] = L".COM;.EXE";
|
45
|
+
|
46
|
+
|
47
|
+
static void uv_process_init(uv_process_t* handle) {
|
48
|
+
handle->type = UV_PROCESS;
|
49
|
+
handle->flags = 0;
|
50
|
+
handle->error = uv_ok_;
|
51
|
+
handle->exit_cb = NULL;
|
52
|
+
handle->pid = 0;
|
53
|
+
handle->exit_signal = 0;
|
54
|
+
handle->wait_handle = INVALID_HANDLE_VALUE;
|
55
|
+
handle->process_handle = INVALID_HANDLE_VALUE;
|
56
|
+
handle->close_handle = INVALID_HANDLE_VALUE;
|
57
|
+
handle->stdio_pipes[0].server_pipe = NULL;
|
58
|
+
handle->stdio_pipes[0].child_pipe = INVALID_HANDLE_VALUE;
|
59
|
+
handle->stdio_pipes[1].server_pipe = NULL;
|
60
|
+
handle->stdio_pipes[1].child_pipe = INVALID_HANDLE_VALUE;
|
61
|
+
handle->stdio_pipes[2].server_pipe = NULL;
|
62
|
+
handle->stdio_pipes[2].child_pipe = INVALID_HANDLE_VALUE;
|
63
|
+
|
64
|
+
uv_req_init((uv_req_t*)&handle->exit_req);
|
65
|
+
handle->exit_req.type = UV_PROCESS_EXIT;
|
66
|
+
handle->exit_req.data = handle;
|
67
|
+
uv_req_init((uv_req_t*)&handle->close_req);
|
68
|
+
handle->close_req.type = UV_PROCESS_CLOSE;
|
69
|
+
handle->close_req.data = handle;
|
70
|
+
|
71
|
+
uv_counters()->handle_init++;
|
72
|
+
uv_counters()->process_init++;
|
73
|
+
|
74
|
+
uv_ref();
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
/*
|
79
|
+
* Path search functions
|
80
|
+
*/
|
81
|
+
|
82
|
+
/*
|
83
|
+
* Helper function for search_path
|
84
|
+
*/
|
85
|
+
static wchar_t* search_path_join_test(const wchar_t* dir,
|
86
|
+
int dir_len,
|
87
|
+
const wchar_t* name,
|
88
|
+
int name_len,
|
89
|
+
const wchar_t* ext,
|
90
|
+
int ext_len,
|
91
|
+
const wchar_t* cwd,
|
92
|
+
int cwd_len) {
|
93
|
+
wchar_t *result, *result_pos;
|
94
|
+
DWORD attrs;
|
95
|
+
|
96
|
+
if (dir_len >= 1 && (dir[0] == L'/' || dir[0] == L'\\')) {
|
97
|
+
/* It's a full path without drive letter, use cwd's drive letter only */
|
98
|
+
cwd_len = 2;
|
99
|
+
} else if (dir_len >= 2 && dir[1] == L':' &&
|
100
|
+
(dir_len < 3 || (dir[2] != L'/' && dir[2] != L'\\'))) {
|
101
|
+
/* It's a relative path with drive letter (ext.g. D:../some/file)
|
102
|
+
* Replace drive letter in dir by full cwd if it points to the same drive,
|
103
|
+
* otherwise use the dir only.
|
104
|
+
*/
|
105
|
+
if (cwd_len < 2 || _wcsnicmp(cwd, dir, 2) != 0) {
|
106
|
+
cwd_len = 0;
|
107
|
+
} else {
|
108
|
+
dir += 2;
|
109
|
+
dir_len -= 2;
|
110
|
+
}
|
111
|
+
} else if (dir_len > 2 && dir[1] == L':') {
|
112
|
+
/* It's an absolute path with drive letter
|
113
|
+
* Don't use the cwd at all
|
114
|
+
*/
|
115
|
+
cwd_len = 0;
|
116
|
+
}
|
117
|
+
|
118
|
+
/* Allocate buffer for output */
|
119
|
+
result = result_pos =
|
120
|
+
(wchar_t*)malloc(sizeof(wchar_t) * (cwd_len + 1 + dir_len + 1 + name_len + 1 + ext_len + 1));
|
121
|
+
|
122
|
+
/* Copy cwd */
|
123
|
+
wcsncpy(result_pos, cwd, cwd_len);
|
124
|
+
result_pos += cwd_len;
|
125
|
+
|
126
|
+
/* Add a path separator if cwd didn't end with one */
|
127
|
+
if (cwd_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) {
|
128
|
+
result_pos[0] = L'\\';
|
129
|
+
result_pos++;
|
130
|
+
}
|
131
|
+
|
132
|
+
/* Copy dir */
|
133
|
+
wcsncpy(result_pos, dir, dir_len);
|
134
|
+
result_pos += dir_len;
|
135
|
+
|
136
|
+
/* Add a separator if the dir didn't end with one */
|
137
|
+
if (dir_len && wcsrchr(L"\\/:", result_pos[-1]) == NULL) {
|
138
|
+
result_pos[0] = L'\\';
|
139
|
+
result_pos++;
|
140
|
+
}
|
141
|
+
|
142
|
+
/* Copy filename */
|
143
|
+
wcsncpy(result_pos, name, name_len);
|
144
|
+
result_pos += name_len;
|
145
|
+
|
146
|
+
/* Copy extension */
|
147
|
+
if (ext_len) {
|
148
|
+
result_pos[0] = L'.';
|
149
|
+
result_pos++;
|
150
|
+
wcsncpy(result_pos, ext, ext_len);
|
151
|
+
result_pos += ext_len;
|
152
|
+
}
|
153
|
+
|
154
|
+
/* Null terminator */
|
155
|
+
result_pos[0] = L'\0';
|
156
|
+
|
157
|
+
attrs = GetFileAttributesW(result);
|
158
|
+
|
159
|
+
if (attrs != INVALID_FILE_ATTRIBUTES &&
|
160
|
+
!(attrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT))) {
|
161
|
+
return result;
|
162
|
+
}
|
163
|
+
|
164
|
+
free(result);
|
165
|
+
return NULL;
|
166
|
+
}
|
167
|
+
|
168
|
+
|
169
|
+
/*
|
170
|
+
* Helper function for search_path
|
171
|
+
*/
|
172
|
+
static wchar_t* path_search_walk_ext(const wchar_t *dir,
|
173
|
+
int dir_len,
|
174
|
+
const wchar_t *name,
|
175
|
+
int name_len,
|
176
|
+
wchar_t *cwd,
|
177
|
+
int cwd_len,
|
178
|
+
const wchar_t *path_ext,
|
179
|
+
int name_has_ext) {
|
180
|
+
wchar_t* result = NULL;
|
181
|
+
|
182
|
+
const wchar_t *ext_start,
|
183
|
+
*ext_end = path_ext;
|
184
|
+
|
185
|
+
/* If the name itself has a nonemtpy extension, try this extension first */
|
186
|
+
if (name_has_ext) {
|
187
|
+
result = search_path_join_test(dir, dir_len,
|
188
|
+
name, name_len,
|
189
|
+
L"", 0,
|
190
|
+
cwd, cwd_len);
|
191
|
+
}
|
192
|
+
|
193
|
+
/* Add path_ext extensions and try to find a name that matches */
|
194
|
+
while (result == NULL) {
|
195
|
+
if (*ext_end == L'\0') {
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
|
199
|
+
/* Skip the separator that ext_end now points to */
|
200
|
+
if (ext_end != path_ext) {
|
201
|
+
ext_end++;
|
202
|
+
}
|
203
|
+
|
204
|
+
/* Find the next dot in path_ext */
|
205
|
+
ext_start = wcschr(ext_end, L'.');
|
206
|
+
if (ext_start == NULL) {
|
207
|
+
break;
|
208
|
+
}
|
209
|
+
|
210
|
+
/* Skip the dot */
|
211
|
+
ext_start++;
|
212
|
+
|
213
|
+
/* Slice until we found a ; or alternatively a \0 */
|
214
|
+
ext_end = wcschr(ext_start, L';');
|
215
|
+
if (ext_end == NULL) {
|
216
|
+
ext_end = wcschr(ext_start, '\0');
|
217
|
+
}
|
218
|
+
|
219
|
+
result = search_path_join_test(dir, dir_len,
|
220
|
+
name, name_len,
|
221
|
+
ext_start, (ext_end - ext_start),
|
222
|
+
cwd, cwd_len);
|
223
|
+
}
|
224
|
+
|
225
|
+
return result;
|
226
|
+
}
|
227
|
+
|
228
|
+
|
229
|
+
/*
|
230
|
+
* search_path searches the system path for an executable filename -
|
231
|
+
* the windows API doesn't provide this as a standalone function nor as an
|
232
|
+
* option to CreateProcess.
|
233
|
+
*
|
234
|
+
* It tries to return an absolute filename.
|
235
|
+
*
|
236
|
+
* Furthermore, it tries to follow the semantics that cmd.exe uses as closely
|
237
|
+
* as possible:
|
238
|
+
*
|
239
|
+
* - Do not search the path if the filename already contains a path (either
|
240
|
+
* relative or absolute).
|
241
|
+
* (but do use path_ext)
|
242
|
+
*
|
243
|
+
* - If there's really only a filename, check the current directory for file,
|
244
|
+
* then search all path directories.
|
245
|
+
*
|
246
|
+
* - If filename specifies has *any* extension, search for the file with the
|
247
|
+
* specified extension first.
|
248
|
+
* (not necessary an executable one or one that appears in path_ext;
|
249
|
+
* *but* no extension or just a dot is *not* allowed)
|
250
|
+
*
|
251
|
+
* - If the literal filename is not found in a directory, try *appending*
|
252
|
+
* (not replacing) extensions from path_ext in the specified order.
|
253
|
+
* (an extension consisting of just a dot *may* appear in path_ext;
|
254
|
+
* unlike what happens if the specified filename ends with a dot,
|
255
|
+
* if path_ext specifies a single dot cmd.exe *does* look for an
|
256
|
+
* extension-less file)
|
257
|
+
*
|
258
|
+
* - The path variable may contain relative paths; relative paths are relative
|
259
|
+
* to the cwd.
|
260
|
+
*
|
261
|
+
* - Directories in path may or may not end with a trailing backslash.
|
262
|
+
*
|
263
|
+
* - Extensions path_ext portions must always start with a dot.
|
264
|
+
*
|
265
|
+
* - CMD does not trim leading/trailing whitespace from path/pathex entries
|
266
|
+
* nor from the environment variables as a whole.
|
267
|
+
*
|
268
|
+
* - When cmd.exe cannot read a directory, it wil just skip it and go on
|
269
|
+
* searching. However, unlike posix-y systems, it will happily try to run a
|
270
|
+
* file that is not readable/executable; if the spawn fails it will not
|
271
|
+
* continue searching.
|
272
|
+
*
|
273
|
+
* TODO: correctly interpret UNC paths
|
274
|
+
* TODO: check with cmd what should happen when a pathext entry does not start
|
275
|
+
* with a dot
|
276
|
+
*/
|
277
|
+
static wchar_t* search_path(const wchar_t *file,
|
278
|
+
wchar_t *cwd,
|
279
|
+
const wchar_t *path,
|
280
|
+
const wchar_t *path_ext) {
|
281
|
+
int file_has_dir;
|
282
|
+
wchar_t* result = NULL;
|
283
|
+
wchar_t *file_name_start;
|
284
|
+
wchar_t *dot;
|
285
|
+
int name_has_ext;
|
286
|
+
|
287
|
+
int file_len = wcslen(file);
|
288
|
+
int cwd_len = wcslen(cwd);
|
289
|
+
|
290
|
+
/* If the caller supplies an empty filename,
|
291
|
+
* we're not gonna return c:\windows\.exe -- GFY!
|
292
|
+
*/
|
293
|
+
if (file_len == 0
|
294
|
+
|| (file_len == 1 && file[0] == L'.')) {
|
295
|
+
return NULL;
|
296
|
+
}
|
297
|
+
|
298
|
+
/* Find the start of the filename so we can split the directory from the name */
|
299
|
+
for (file_name_start = (wchar_t*)file + file_len;
|
300
|
+
file_name_start > file
|
301
|
+
&& file_name_start[-1] != L'\\'
|
302
|
+
&& file_name_start[-1] != L'/'
|
303
|
+
&& file_name_start[-1] != L':';
|
304
|
+
file_name_start--);
|
305
|
+
|
306
|
+
file_has_dir = file_name_start != file;
|
307
|
+
|
308
|
+
/* Check if the filename includes an extension */
|
309
|
+
dot = wcschr(file_name_start, L'.');
|
310
|
+
name_has_ext = (dot != NULL && dot[1] != L'\0');
|
311
|
+
|
312
|
+
if (file_has_dir) {
|
313
|
+
/* The file has a path inside, don't use path (but do use path_ex) */
|
314
|
+
result = path_search_walk_ext(
|
315
|
+
file, file_name_start - file,
|
316
|
+
file_name_start, file_len - (file_name_start - file),
|
317
|
+
cwd, cwd_len,
|
318
|
+
path_ext, name_has_ext);
|
319
|
+
|
320
|
+
} else {
|
321
|
+
const wchar_t *dir_start,
|
322
|
+
*dir_end = path;
|
323
|
+
|
324
|
+
/* The file is really only a name; look in cwd first, then scan path */
|
325
|
+
result = path_search_walk_ext(L"", 0,
|
326
|
+
file, file_len,
|
327
|
+
cwd, cwd_len,
|
328
|
+
path_ext, name_has_ext);
|
329
|
+
|
330
|
+
while (result == NULL) {
|
331
|
+
if (*dir_end == L'\0') {
|
332
|
+
break;
|
333
|
+
}
|
334
|
+
|
335
|
+
/* Skip the separator that dir_end now points to */
|
336
|
+
if (dir_end != path) {
|
337
|
+
dir_end++;
|
338
|
+
}
|
339
|
+
|
340
|
+
/* Next slice starts just after where the previous one ended */
|
341
|
+
dir_start = dir_end;
|
342
|
+
|
343
|
+
/* Slice until the next ; or \0 is found */
|
344
|
+
dir_end = wcschr(dir_start, L';');
|
345
|
+
if (dir_end == NULL) {
|
346
|
+
dir_end = wcschr(dir_start, L'\0');
|
347
|
+
}
|
348
|
+
|
349
|
+
/* If the slice is zero-length, don't bother */
|
350
|
+
if (dir_end - dir_start == 0) {
|
351
|
+
continue;
|
352
|
+
}
|
353
|
+
|
354
|
+
result = path_search_walk_ext(dir_start, dir_end - dir_start,
|
355
|
+
file, file_len,
|
356
|
+
cwd, cwd_len,
|
357
|
+
path_ext, name_has_ext);
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
return result;
|
362
|
+
}
|
363
|
+
|
364
|
+
/*
|
365
|
+
* Quotes command line arguments
|
366
|
+
* Returns a pointer to the end (next char to be written) of the buffer
|
367
|
+
*/
|
368
|
+
wchar_t* quote_cmd_arg(const wchar_t *source, wchar_t *target) {
|
369
|
+
int len = wcslen(source),
|
370
|
+
i, quote_hit;
|
371
|
+
wchar_t* start;
|
372
|
+
|
373
|
+
/*
|
374
|
+
* Check if the string must be quoted;
|
375
|
+
* if unnecessary, don't do it, it may only confuse older programs.
|
376
|
+
*/
|
377
|
+
if (len == 0) {
|
378
|
+
return target;
|
379
|
+
}
|
380
|
+
|
381
|
+
if (NULL == wcspbrk(source, L" \t\"")) {
|
382
|
+
/* No quotation needed */
|
383
|
+
wcsncpy(target, source, len);
|
384
|
+
target += len;
|
385
|
+
return target;
|
386
|
+
}
|
387
|
+
|
388
|
+
if (NULL == wcspbrk(source, L"\"\\")) {
|
389
|
+
/*
|
390
|
+
* No embedded double quotes or backlashes, so I can just wrap
|
391
|
+
* quote marks around the whole thing.
|
392
|
+
*/
|
393
|
+
*(target++) = L'"';
|
394
|
+
wcsncpy(target, source, len);
|
395
|
+
target += len;
|
396
|
+
*(target++) = L'"';
|
397
|
+
return target;
|
398
|
+
}
|
399
|
+
|
400
|
+
/*
|
401
|
+
* Expected intput/output:
|
402
|
+
* input : hello"world
|
403
|
+
* output: "hello\"world"
|
404
|
+
* input : hello""world
|
405
|
+
* output: "hello\"\"world"
|
406
|
+
* input : hello\world
|
407
|
+
* output: hello\world
|
408
|
+
* input : hello\\world
|
409
|
+
* output: hello\\world
|
410
|
+
* input : hello\"world
|
411
|
+
* output: "hello\\\"world"
|
412
|
+
* input : hello\\"world
|
413
|
+
* output: "hello\\\\\"world"
|
414
|
+
* input : hello world\
|
415
|
+
* output: "hello world\"
|
416
|
+
*/
|
417
|
+
|
418
|
+
*(target++) = L'"';
|
419
|
+
start = target;
|
420
|
+
quote_hit = 1;
|
421
|
+
|
422
|
+
for (i = len; i > 0; --i) {
|
423
|
+
*(target++) = source[i - 1];
|
424
|
+
|
425
|
+
if (quote_hit && source[i - 1] == L'\\') {
|
426
|
+
*(target++) = L'\\';
|
427
|
+
} else if(source[i - 1] == L'"') {
|
428
|
+
quote_hit = 1;
|
429
|
+
*(target++) = L'\\';
|
430
|
+
} else {
|
431
|
+
quote_hit = 0;
|
432
|
+
}
|
433
|
+
}
|
434
|
+
target[0] = L'\0';
|
435
|
+
wcsrev(start);
|
436
|
+
*(target++) = L'"';
|
437
|
+
return target;
|
438
|
+
}
|
439
|
+
|
440
|
+
wchar_t* make_program_args(char** args, int verbatim_arguments) {
|
441
|
+
wchar_t* dst;
|
442
|
+
wchar_t* ptr;
|
443
|
+
char** arg;
|
444
|
+
size_t size = 0;
|
445
|
+
size_t len;
|
446
|
+
int arg_count = 0;
|
447
|
+
wchar_t* buffer;
|
448
|
+
int arg_size;
|
449
|
+
int buffer_size = 0;
|
450
|
+
|
451
|
+
/* Count the required size. */
|
452
|
+
for (arg = args; *arg; arg++) {
|
453
|
+
arg_size = uv_utf8_to_utf16(*arg, NULL, 0) * sizeof(wchar_t);
|
454
|
+
size += arg_size;
|
455
|
+
buffer_size = arg_size > buffer_size ? arg_size : buffer_size;
|
456
|
+
arg_count++;
|
457
|
+
}
|
458
|
+
|
459
|
+
/* Adjust for potential quotes. Also assume the worst-case scenario
|
460
|
+
/* that every character needs escaping, so we need twice as much space. */
|
461
|
+
size = size * 2 + arg_count * 2;
|
462
|
+
|
463
|
+
dst = (wchar_t*)malloc(size);
|
464
|
+
if (!dst) {
|
465
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
466
|
+
}
|
467
|
+
|
468
|
+
buffer = (wchar_t*)malloc(buffer_size);
|
469
|
+
if (!buffer) {
|
470
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
471
|
+
}
|
472
|
+
|
473
|
+
ptr = dst;
|
474
|
+
for (arg = args; *arg; arg++) {
|
475
|
+
len = uv_utf8_to_utf16(*arg, buffer, (size_t)(size - (ptr - dst)));
|
476
|
+
if (!len) {
|
477
|
+
goto error;
|
478
|
+
}
|
479
|
+
if (verbatim_arguments) {
|
480
|
+
wcscpy(ptr, buffer);
|
481
|
+
ptr += len - 1;
|
482
|
+
} else {
|
483
|
+
ptr = quote_cmd_arg(buffer, ptr);
|
484
|
+
}
|
485
|
+
*ptr++ = *(arg + 1) ? L' ' : L'\0';
|
486
|
+
}
|
487
|
+
|
488
|
+
free(buffer);
|
489
|
+
return dst;
|
490
|
+
|
491
|
+
error:
|
492
|
+
free(dst);
|
493
|
+
free(buffer);
|
494
|
+
return NULL;
|
495
|
+
}
|
496
|
+
|
497
|
+
/*
|
498
|
+
* The way windows takes environment variables is different than what C does;
|
499
|
+
* Windows wants a contiguous block of null-terminated strings, terminated
|
500
|
+
* with an additional null.
|
501
|
+
*/
|
502
|
+
wchar_t* make_program_env(char** env_block) {
|
503
|
+
wchar_t* dst;
|
504
|
+
wchar_t* ptr;
|
505
|
+
char** env;
|
506
|
+
int env_len = 1 * sizeof(wchar_t); /* room for closing null */
|
507
|
+
int len;
|
508
|
+
|
509
|
+
for (env = env_block; *env; env++) {
|
510
|
+
env_len += (uv_utf8_to_utf16(*env, NULL, 0) * sizeof(wchar_t));
|
511
|
+
}
|
512
|
+
|
513
|
+
dst = (wchar_t*)malloc(env_len);
|
514
|
+
if (!dst) {
|
515
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
516
|
+
}
|
517
|
+
|
518
|
+
ptr = dst;
|
519
|
+
|
520
|
+
for (env = env_block; *env; env++, ptr += len) {
|
521
|
+
len = uv_utf8_to_utf16(*env, ptr, (size_t)(env_len - (ptr - dst)));
|
522
|
+
if (!len) {
|
523
|
+
free(dst);
|
524
|
+
return NULL;
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
*ptr = L'\0';
|
529
|
+
return dst;
|
530
|
+
}
|
531
|
+
|
532
|
+
|
533
|
+
/*
|
534
|
+
* Called on Windows thread-pool thread to indicate that
|
535
|
+
* a child process has exited.
|
536
|
+
*/
|
537
|
+
static void CALLBACK exit_wait_callback(void* data, BOOLEAN didTimeout) {
|
538
|
+
uv_process_t* process = (uv_process_t*)data;
|
539
|
+
|
540
|
+
assert(didTimeout == FALSE);
|
541
|
+
assert(process);
|
542
|
+
|
543
|
+
memset(&process->exit_req.overlapped, 0, sizeof(process->exit_req.overlapped));
|
544
|
+
|
545
|
+
/* Post completed */
|
546
|
+
if (!PostQueuedCompletionStatus(LOOP->iocp,
|
547
|
+
0,
|
548
|
+
0,
|
549
|
+
&process->exit_req.overlapped)) {
|
550
|
+
uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus");
|
551
|
+
}
|
552
|
+
}
|
553
|
+
|
554
|
+
|
555
|
+
/*
|
556
|
+
* Called on Windows thread-pool thread to indicate that
|
557
|
+
* UnregisterWaitEx has completed.
|
558
|
+
*/
|
559
|
+
static void CALLBACK close_wait_callback(void* data, BOOLEAN didTimeout) {
|
560
|
+
uv_process_t* process = (uv_process_t*)data;
|
561
|
+
|
562
|
+
assert(didTimeout == FALSE);
|
563
|
+
assert(process);
|
564
|
+
|
565
|
+
memset(&process->close_req.overlapped, 0, sizeof(process->close_req.overlapped));
|
566
|
+
|
567
|
+
/* Post completed */
|
568
|
+
if (!PostQueuedCompletionStatus(LOOP->iocp,
|
569
|
+
0,
|
570
|
+
0,
|
571
|
+
&process->close_req.overlapped)) {
|
572
|
+
uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus");
|
573
|
+
}
|
574
|
+
}
|
575
|
+
|
576
|
+
|
577
|
+
/*
|
578
|
+
* Called on windows thread pool when CreateProcess failed. It writes an error
|
579
|
+
* message to the process' intended stderr and then posts a PROCESS_EXIT
|
580
|
+
* packet to the completion port.
|
581
|
+
*/
|
582
|
+
static DWORD WINAPI spawn_failure(void* data) {
|
583
|
+
char syscall[] = "CreateProcessW: ";
|
584
|
+
char unknown[] = "unknown error\n";
|
585
|
+
uv_process_t* process = (uv_process_t*) data;
|
586
|
+
HANDLE child_stderr = process->stdio_pipes[2].child_pipe;
|
587
|
+
char* buf = NULL;
|
588
|
+
DWORD count, written;
|
589
|
+
|
590
|
+
WriteFile(child_stderr, syscall, sizeof(syscall) - 1, &written, NULL);
|
591
|
+
|
592
|
+
count = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
593
|
+
FORMAT_MESSAGE_FROM_SYSTEM |
|
594
|
+
FORMAT_MESSAGE_IGNORE_INSERTS,
|
595
|
+
NULL,
|
596
|
+
process->spawn_errno,
|
597
|
+
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
598
|
+
(LPSTR) &buf,
|
599
|
+
0,
|
600
|
+
NULL);
|
601
|
+
|
602
|
+
if (buf != NULL && count > 0) {
|
603
|
+
WriteFile(child_stderr, buf, count, &written, NULL);
|
604
|
+
LocalFree(buf);
|
605
|
+
} else {
|
606
|
+
WriteFile(child_stderr, unknown, sizeof(unknown) - 1, &written, NULL);
|
607
|
+
}
|
608
|
+
|
609
|
+
FlushFileBuffers(child_stderr);
|
610
|
+
|
611
|
+
memset(&process->exit_req.overlapped, 0, sizeof(process->exit_req.overlapped));
|
612
|
+
|
613
|
+
/* Post completed */
|
614
|
+
if (!PostQueuedCompletionStatus(LOOP->iocp,
|
615
|
+
0,
|
616
|
+
0,
|
617
|
+
&process->exit_req.overlapped)) {
|
618
|
+
uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus");
|
619
|
+
}
|
620
|
+
|
621
|
+
return 0;
|
622
|
+
}
|
623
|
+
|
624
|
+
|
625
|
+
/* Called on main thread after a child process has exited. */
|
626
|
+
void uv_process_proc_exit(uv_process_t* handle) {
|
627
|
+
int i;
|
628
|
+
DWORD exit_code;
|
629
|
+
|
630
|
+
/* Close stdio handles. */
|
631
|
+
for (i = 0; i < COUNTOF(handle->stdio_pipes); i++) {
|
632
|
+
if (handle->stdio_pipes[i].child_pipe != INVALID_HANDLE_VALUE) {
|
633
|
+
CloseHandle(handle->stdio_pipes[i].child_pipe);
|
634
|
+
handle->stdio_pipes[i].child_pipe = INVALID_HANDLE_VALUE;
|
635
|
+
}
|
636
|
+
}
|
637
|
+
|
638
|
+
/* Unregister from process notification. */
|
639
|
+
if (handle->wait_handle != INVALID_HANDLE_VALUE) {
|
640
|
+
UnregisterWait(handle->wait_handle);
|
641
|
+
handle->wait_handle = INVALID_HANDLE_VALUE;
|
642
|
+
}
|
643
|
+
|
644
|
+
if (handle->process_handle != INVALID_HANDLE_VALUE) {
|
645
|
+
/* Get the exit code. */
|
646
|
+
if (!GetExitCodeProcess(handle->process_handle, &exit_code)) {
|
647
|
+
exit_code = 127;
|
648
|
+
}
|
649
|
+
|
650
|
+
/* Clean-up the process handle. */
|
651
|
+
CloseHandle(handle->process_handle);
|
652
|
+
handle->process_handle = INVALID_HANDLE_VALUE;
|
653
|
+
} else {
|
654
|
+
/* The process never even started in the first place. */
|
655
|
+
exit_code = 127;
|
656
|
+
}
|
657
|
+
|
658
|
+
/* Fire the exit callback. */
|
659
|
+
if (handle->exit_cb) {
|
660
|
+
handle->exit_cb(handle, exit_code, handle->exit_signal);
|
661
|
+
}
|
662
|
+
}
|
663
|
+
|
664
|
+
|
665
|
+
/* Called on main thread after UnregisterWaitEx finishes. */
|
666
|
+
void uv_process_proc_close(uv_process_t* handle) {
|
667
|
+
uv_want_endgame((uv_handle_t*)handle);
|
668
|
+
}
|
669
|
+
|
670
|
+
|
671
|
+
void uv_process_endgame(uv_process_t* handle) {
|
672
|
+
if (handle->flags & UV_HANDLE_CLOSING) {
|
673
|
+
assert(!(handle->flags & UV_HANDLE_CLOSED));
|
674
|
+
handle->flags |= UV_HANDLE_CLOSED;
|
675
|
+
|
676
|
+
if (handle->close_cb) {
|
677
|
+
handle->close_cb((uv_handle_t*)handle);
|
678
|
+
}
|
679
|
+
|
680
|
+
uv_unref();
|
681
|
+
}
|
682
|
+
}
|
683
|
+
|
684
|
+
|
685
|
+
void uv_process_close(uv_process_t* handle) {
|
686
|
+
if (handle->wait_handle != INVALID_HANDLE_VALUE) {
|
687
|
+
handle->close_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
|
688
|
+
UnregisterWaitEx(handle->wait_handle, handle->close_handle);
|
689
|
+
handle->wait_handle = NULL;
|
690
|
+
|
691
|
+
RegisterWaitForSingleObject(&handle->wait_handle, handle->close_handle,
|
692
|
+
close_wait_callback, (void*)handle, INFINITE,
|
693
|
+
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE);
|
694
|
+
} else {
|
695
|
+
uv_want_endgame((uv_handle_t*)handle);
|
696
|
+
}
|
697
|
+
}
|
698
|
+
|
699
|
+
|
700
|
+
static int uv_create_stdio_pipe_pair(uv_pipe_t* server_pipe, HANDLE* child_pipe, DWORD server_access, DWORD child_access) {
|
701
|
+
int err;
|
702
|
+
SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };
|
703
|
+
char pipe_name[64];
|
704
|
+
DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
|
705
|
+
|
706
|
+
if (server_pipe->type != UV_NAMED_PIPE) {
|
707
|
+
uv_set_error(UV_EINVAL, 0);
|
708
|
+
err = -1;
|
709
|
+
goto done;
|
710
|
+
}
|
711
|
+
|
712
|
+
/* Create server pipe handle. */
|
713
|
+
err = uv_stdio_pipe_server(server_pipe, server_access, pipe_name, sizeof(pipe_name));
|
714
|
+
if (err) {
|
715
|
+
goto done;
|
716
|
+
}
|
717
|
+
|
718
|
+
/* Create child pipe handle. */
|
719
|
+
*child_pipe = CreateFileA(pipe_name,
|
720
|
+
child_access,
|
721
|
+
0,
|
722
|
+
&sa,
|
723
|
+
OPEN_EXISTING,
|
724
|
+
0,
|
725
|
+
NULL);
|
726
|
+
|
727
|
+
if (*child_pipe == INVALID_HANDLE_VALUE) {
|
728
|
+
uv_set_sys_error(GetLastError());
|
729
|
+
err = -1;
|
730
|
+
goto done;
|
731
|
+
}
|
732
|
+
|
733
|
+
if (!SetNamedPipeHandleState(*child_pipe, &mode, NULL, NULL)) {
|
734
|
+
uv_set_sys_error(GetLastError());
|
735
|
+
err = -1;
|
736
|
+
goto done;
|
737
|
+
}
|
738
|
+
|
739
|
+
/* Do a blocking ConnectNamedPipe. This should not block because
|
740
|
+
* we have both ends of the pipe created.
|
741
|
+
*/
|
742
|
+
if (!ConnectNamedPipe(server_pipe->handle, NULL)) {
|
743
|
+
if (GetLastError() != ERROR_PIPE_CONNECTED) {
|
744
|
+
uv_set_sys_error(GetLastError());
|
745
|
+
err = -1;
|
746
|
+
goto done;
|
747
|
+
}
|
748
|
+
}
|
749
|
+
|
750
|
+
err = 0;
|
751
|
+
|
752
|
+
done:
|
753
|
+
if (err) {
|
754
|
+
if (server_pipe->handle != INVALID_HANDLE_VALUE) {
|
755
|
+
close_pipe(server_pipe, NULL, NULL);
|
756
|
+
}
|
757
|
+
|
758
|
+
if (*child_pipe != INVALID_HANDLE_VALUE) {
|
759
|
+
CloseHandle(*child_pipe);
|
760
|
+
*child_pipe = INVALID_HANDLE_VALUE;
|
761
|
+
}
|
762
|
+
}
|
763
|
+
|
764
|
+
return err;
|
765
|
+
}
|
766
|
+
|
767
|
+
|
768
|
+
int uv_spawn(uv_process_t* process, uv_process_options_t options) {
|
769
|
+
int err = 0, i;
|
770
|
+
wchar_t* path;
|
771
|
+
int size;
|
772
|
+
wchar_t* application_path, *application, *arguments, *env, *cwd;
|
773
|
+
STARTUPINFOW startup;
|
774
|
+
PROCESS_INFORMATION info;
|
775
|
+
|
776
|
+
uv_process_init(process);
|
777
|
+
|
778
|
+
process->exit_cb = options.exit_cb;
|
779
|
+
UTF8_TO_UTF16(options.file, application);
|
780
|
+
arguments = options.args ? make_program_args(options.args, options.windows_verbatim_arguments) : NULL;
|
781
|
+
env = options.env ? make_program_env(options.env) : NULL;
|
782
|
+
|
783
|
+
if (options.cwd) {
|
784
|
+
UTF8_TO_UTF16(options.cwd, cwd);
|
785
|
+
} else {
|
786
|
+
size = GetCurrentDirectoryW(0, NULL) * sizeof(wchar_t);
|
787
|
+
if (size) {
|
788
|
+
cwd = (wchar_t*)malloc(size);
|
789
|
+
if (!cwd) {
|
790
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
791
|
+
}
|
792
|
+
GetCurrentDirectoryW(size, cwd);
|
793
|
+
} else {
|
794
|
+
uv_set_sys_error(GetLastError());
|
795
|
+
err = -1;
|
796
|
+
goto done;
|
797
|
+
}
|
798
|
+
}
|
799
|
+
|
800
|
+
/* Get PATH env. variable. */
|
801
|
+
size = GetEnvironmentVariableW(L"PATH", NULL, 0) + 1;
|
802
|
+
path = (wchar_t*)malloc(size * sizeof(wchar_t));
|
803
|
+
if (!path) {
|
804
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
805
|
+
}
|
806
|
+
GetEnvironmentVariableW(L"PATH", path, size * sizeof(wchar_t));
|
807
|
+
path[size - 1] = L'\0';
|
808
|
+
|
809
|
+
application_path = search_path(application,
|
810
|
+
cwd,
|
811
|
+
path,
|
812
|
+
DEFAULT_PATH_EXT);
|
813
|
+
|
814
|
+
if (!application_path) {
|
815
|
+
/* CreateProcess will fail, but this allows us to pass this error to */
|
816
|
+
/* the user asynchronously. */
|
817
|
+
application_path = application;
|
818
|
+
}
|
819
|
+
|
820
|
+
/* Create stdio pipes. */
|
821
|
+
if (options.stdin_stream) {
|
822
|
+
err = uv_create_stdio_pipe_pair(options.stdin_stream, &process->stdio_pipes[0].child_pipe, PIPE_ACCESS_OUTBOUND, GENERIC_READ | FILE_WRITE_ATTRIBUTES);
|
823
|
+
if (err) {
|
824
|
+
goto done;
|
825
|
+
}
|
826
|
+
|
827
|
+
process->stdio_pipes[0].server_pipe = options.stdin_stream;
|
828
|
+
}
|
829
|
+
|
830
|
+
if (options.stdout_stream) {
|
831
|
+
err = uv_create_stdio_pipe_pair(options.stdout_stream, &process->stdio_pipes[1].child_pipe, PIPE_ACCESS_INBOUND, GENERIC_WRITE);
|
832
|
+
if (err) {
|
833
|
+
goto done;
|
834
|
+
}
|
835
|
+
|
836
|
+
process->stdio_pipes[1].server_pipe = options.stdout_stream;
|
837
|
+
}
|
838
|
+
|
839
|
+
if (options.stderr_stream) {
|
840
|
+
err = uv_create_stdio_pipe_pair(options.stderr_stream, &process->stdio_pipes[2].child_pipe, PIPE_ACCESS_INBOUND, GENERIC_WRITE);
|
841
|
+
if (err) {
|
842
|
+
goto done;
|
843
|
+
}
|
844
|
+
|
845
|
+
process->stdio_pipes[2].server_pipe = options.stderr_stream;
|
846
|
+
}
|
847
|
+
|
848
|
+
startup.cb = sizeof(startup);
|
849
|
+
startup.lpReserved = NULL;
|
850
|
+
startup.lpDesktop = NULL;
|
851
|
+
startup.lpTitle = NULL;
|
852
|
+
startup.dwFlags = STARTF_USESTDHANDLES;
|
853
|
+
startup.cbReserved2 = 0;
|
854
|
+
startup.lpReserved2 = NULL;
|
855
|
+
startup.hStdInput = process->stdio_pipes[0].child_pipe;
|
856
|
+
startup.hStdOutput = process->stdio_pipes[1].child_pipe;
|
857
|
+
startup.hStdError = process->stdio_pipes[2].child_pipe;
|
858
|
+
|
859
|
+
if (CreateProcessW(application_path,
|
860
|
+
arguments,
|
861
|
+
NULL,
|
862
|
+
NULL,
|
863
|
+
1,
|
864
|
+
CREATE_UNICODE_ENVIRONMENT,
|
865
|
+
env,
|
866
|
+
cwd,
|
867
|
+
&startup,
|
868
|
+
&info)) {
|
869
|
+
/* Spawn succeeded */
|
870
|
+
process->process_handle = info.hProcess;
|
871
|
+
process->pid = info.dwProcessId;
|
872
|
+
|
873
|
+
/* Setup notifications for when the child process exits. */
|
874
|
+
if (!RegisterWaitForSingleObject(&process->wait_handle, process->process_handle,
|
875
|
+
exit_wait_callback, (void*)process, INFINITE,
|
876
|
+
WT_EXECUTEINWAITTHREAD | WT_EXECUTEONLYONCE)) {
|
877
|
+
uv_fatal_error(GetLastError(), "RegisterWaitForSingleObject");
|
878
|
+
}
|
879
|
+
|
880
|
+
CloseHandle(info.hThread);
|
881
|
+
|
882
|
+
} else {
|
883
|
+
/* CreateProcessW failed, but this failure should be delivered */
|
884
|
+
/* asynchronously to retain unix compatibility. So pretent spawn */
|
885
|
+
/* succeeded, and start a thread instead that prints an error */
|
886
|
+
/* to the child's intended stderr. */
|
887
|
+
process->spawn_errno = GetLastError();
|
888
|
+
if (!QueueUserWorkItem(spawn_failure, process, WT_EXECUTEDEFAULT)) {
|
889
|
+
uv_fatal_error(GetLastError(), "QueueUserWorkItem");
|
890
|
+
}
|
891
|
+
}
|
892
|
+
|
893
|
+
done:
|
894
|
+
free(application);
|
895
|
+
if (application_path != application) {
|
896
|
+
free(application_path);
|
897
|
+
}
|
898
|
+
free(arguments);
|
899
|
+
free(cwd);
|
900
|
+
free(env);
|
901
|
+
free(path);
|
902
|
+
|
903
|
+
if (err) {
|
904
|
+
for (i = 0; i < COUNTOF(process->stdio_pipes); i++) {
|
905
|
+
if (process->stdio_pipes[i].child_pipe != INVALID_HANDLE_VALUE) {
|
906
|
+
CloseHandle(process->stdio_pipes[i].child_pipe);
|
907
|
+
process->stdio_pipes[i].child_pipe = INVALID_HANDLE_VALUE;
|
908
|
+
}
|
909
|
+
}
|
910
|
+
|
911
|
+
if (process->wait_handle != INVALID_HANDLE_VALUE) {
|
912
|
+
UnregisterWait(process->wait_handle);
|
913
|
+
process->wait_handle = INVALID_HANDLE_VALUE;
|
914
|
+
}
|
915
|
+
|
916
|
+
if (process->process_handle != INVALID_HANDLE_VALUE) {
|
917
|
+
CloseHandle(process->process_handle);
|
918
|
+
process->process_handle = INVALID_HANDLE_VALUE;
|
919
|
+
}
|
920
|
+
}
|
921
|
+
|
922
|
+
return err;
|
923
|
+
}
|
924
|
+
|
925
|
+
|
926
|
+
int uv_process_kill(uv_process_t* process, int signum) {
|
927
|
+
process->exit_signal = signum;
|
928
|
+
|
929
|
+
/* On windows killed processes normally return 1 */
|
930
|
+
if (process->process_handle != INVALID_HANDLE_VALUE &&
|
931
|
+
TerminateProcess(process->process_handle, 1)) {
|
932
|
+
return 0;
|
933
|
+
}
|
934
|
+
|
935
|
+
return -1;
|
936
|
+
}
|