robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
fd05c7f19d
master
1/// Helper program to exit and keep stdout open (like "xclip -i -loops 1"). 2#include <stdio.h> 3#include <uv.h> 4 5int main (int argc ,char ** argv ) 6{ 7uv_loop_t * loop = uv_default_loop (); 8uv_process_t child_req ; 9 10char * args [3 ]; 11args [0 ]= "sleep" ; 12args [1 ]= "10" ; 13args [2 ]= NULL ; 14 15uv_process_options_t options = { 16 .exit_cb = NULL , 17 .file = "sleep" , 18 .args = args , 19 .flags = UV_PROCESS_DETACHED , 20 }; 21 22int r ; 23if ((r = uv_spawn (loop ,& child_req ,& options ))) { 24fprintf (stderr ,"%s\n" ,uv_strerror (r )); 25return 1 ; 26 } 27fprintf (stderr ,"pid: %d\n" ,child_req .pid ); 28uv_unref ((uv_handle_t * )& child_req ); 29 30return uv_run (loop ,UV_RUN_DEFAULT ); 31}