@@ -41,7 +41,7 @@ static int
4141setup_write (void * * state )
4242{
4343 (void ) state ; /* unused */
44- int fd ;
44+ int fd , pipes [ 2 ] ;
4545 struct wr * w ;
4646
4747 w = malloc (sizeof * w );
@@ -58,14 +58,16 @@ setup_write(void **state)
5858 lys_parse_fd (w -> session -> ctx , fd , LYS_IN_YIN );
5959 close (fd );
6060
61+ pipe (pipes );
62+
6163 w -> session -> status = NC_STATUS_RUNNING ;
6264 w -> session -> version = NC_VERSION_10 ;
6365 w -> session -> opts .client .msgid = 999 ;
6466 w -> session -> ti_type = NC_TI_FD ;
6567 w -> session -> io_lock = malloc (sizeof * w -> session -> io_lock );
6668 pthread_mutex_init (w -> session -> io_lock , NULL );
67- w -> session -> ti .fd .in = STDIN_FILENO ;
68- w -> session -> ti .fd .out = STDOUT_FILENO ;
69+ w -> session -> ti .fd .in = pipes [ 0 ] ;
70+ w -> session -> ti .fd .out = pipes [ 1 ] ;
6971
7072 /* get rpc to write */
7173 w -> rpc = nc_rpc_lock (NC_DATASTORE_RUNNING );
@@ -82,7 +84,9 @@ teardown_write(void **state)
8284 struct wr * w = (struct wr * )* state ;
8385
8486 nc_rpc_free (w -> rpc );
87+ close (w -> session -> ti .fd .in );
8588 w -> session -> ti .fd .in = -1 ;
89+ close (w -> session -> ti .fd .out );
8690 w -> session -> ti .fd .out = -1 ;
8791 nc_session_free (w -> session , NULL );
8892 free (w );
0 commit comments