summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-01-06 17:58:53 -0500
committermidipix <writeonce@midipix.org>2017-01-07 11:41:13 -0500
commitfaa67f2d8565107fab44d4c5ae9fa1b0b3d19b29 (patch)
tree87ca370afe4ba2ad7c56e262053e0fd8b3f0de6f /src
parent6db2d72937ec42179f9b07a560e75b49603ced56 (diff)
downloadptycon-faa67f2d8565107fab44d4c5ae9fa1b0b3d19b29.tar.bz2
ptycon-faa67f2d8565107fab44d4c5ae9fa1b0b3d19b29.tar.xz
process initialization: swap threads cleanly.
Diffstat (limited to 'src')
-rw-r--r--src/ptycon.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ptycon.c b/src/ptycon.c
index 5caa104..323ab51 100644
--- a/src/ptycon.c
+++ b/src/ptycon.c
@@ -122,14 +122,15 @@ static int32_t ptycon_start(int argc, char ** argv, char ** envp)
return ptyc_main(argc,argv,envp);
}
-static int __stdcall ptycon_daemon_entry_point(void * arg)
+static int __stdcall ptycon_daemon_entry_point(void * hswap)
{
int32_t status;
int argc;
char ** argv;
char ** envp;
- (void)arg;
+ ntapi->zw_set_event(hswap,0);
+ ntapi->zw_close(hswap);
if ((status = ntapi->tt_get_argv_envp_utf8(
&argc,&argv,&envp,
@@ -146,15 +147,23 @@ int ptycon_entry_point(void)
{
int32_t status;
nt_thread_params params;
+ void * hswap;
if ((status = ptyc_init()))
return status;
+ if ((status = ntapi->tt_create_private_event(
+ &hswap,
+ NT_NOTIFICATION_EVENT,
+ NT_EVENT_NOT_SIGNALED)))
+ return status;
+
ntapi->tt_aligned_block_memset(
&params,0,sizeof(params));
params.hprocess = NT_CURRENT_PROCESS_HANDLE;
params.start = ptycon_daemon_entry_point;
+ params.arg = hswap;
params.stack_size_commit = 128 * 1024;
params.stack_size_reserve = 128 * 1024;
params.creation_flags = NT_CREATE_LOCAL_THREAD;
@@ -162,6 +171,9 @@ int ptycon_entry_point(void)
if ((status = ntapi->tt_create_thread(&params)))
ptycon_exit(status);
+ ntapi->zw_wait_for_single_object(
+ hswap,NT_SYNC_NON_ALERTABLE,0);
+
ntapi->zw_close(
params.hthread);