@@ -771,41 +771,41 @@ internal OS_Handle
771771os_process_launch (OS_ProcessLaunchParams * params )
772772{
773773 OS_Handle handle = {0 };
774-
774+
775775 posix_spawn_file_actions_t file_actions = {0 };
776776 int file_actions_init_code = posix_spawn_file_actions_init (& file_actions );
777777 if (file_actions_init_code == 0 )
778778 {
779779 // redirect STDOUT
780780 int stdout_code = posix_spawn_file_actions_adddup2 (& file_actions , (int )params -> stdout_file .u64 [0 ], STDOUT_FILENO );
781781 Assert (stdout_code == 0 );
782-
782+
783783 // redirect STDERR
784784 int stderr_code = posix_spawn_file_actions_adddup2 (& file_actions , (int )params -> stderr_file .u64 [0 ], STDERR_FILENO );
785785 Assert (stderr_code == 0 );
786-
786+
787787 // redirect STDIN
788788 int stdin_code = posix_spawn_file_actions_adddup2 (& file_actions , (int )params -> stdin_file .u64 [0 ], STDIN_FILENO );
789789 Assert (stdin_code == 0 );
790-
790+
791791 posix_spawnattr_t attr = {0 };
792792 int attr_init_code = posix_spawnattr_init (& attr );
793793 if (attr_init_code == 0 )
794794 {
795795 Temp scratch = scratch_begin (0 , 0 );
796-
796+
797797 // package argv
798798 char * * argv = push_array (scratch .arena , char * , params -> cmd_line .node_count + 1 );
799799 {
800800 String8List l = str8_split_path (scratch .arena , params -> path );
801801 str8_list_push (scratch .arena , & l , params -> cmd_line .first -> string );
802802 String8 path_to_exe = str8_path_list_join_by_style (scratch .arena , & l , PathStyle_SystemAbsolute );
803-
803+
804804 argv [0 ] = (char * )path_to_exe .str ;
805805 U64 arg_idx = 1 ;
806806 for EachNode (n , String8Node , params -> cmd_line .first -> next ) { argv [arg_idx ++ ] = (char * )n -> string .str ; }
807807 }
808-
808+
809809 // package envp
810810 char * * envp = 0 ;
811811 if (params -> inherit_env )
@@ -821,39 +821,39 @@ os_process_launch(OS_ProcessLaunchParams *params)
821821 envp [env_idx ] = (char * )n -> string .str ;
822822 }
823823 }
824-
824+
825825 if (params -> debug_subprocesses )
826826 {
827827 // not suported
828828 InvalidPath ;
829829 }
830-
830+
831831 if (!params -> consoleless )
832832 {
833833 NotImplemented ;
834834 }
835-
835+
836836 // spawn process
837837 pid_t pid = 0 ;
838838 int spawn_code = posix_spawn (& pid , argv [0 ], & file_actions , & attr , argv , envp );
839-
839+
840840 if (spawn_code == 0 )
841841 {
842842 handle .u64 [0 ] = (U64 )pid ;
843843 }
844-
844+
845845 // clean up attributes
846846 int attr_destroy_code = posix_spawnattr_destroy (& attr );
847847 Assert (attr_destroy_code == 0 );
848-
848+
849849 scratch_end (scratch );
850850 }
851-
851+
852852 // clean up file actions
853853 int file_actions_destroy_code = posix_spawn_file_actions_destroy (& file_actions );
854854 Assert (file_actions_destroy_code == 0 );
855855 }
856-
856+
857857 return handle ;
858858}
859859
@@ -867,7 +867,7 @@ os_process_join(OS_Handle handle, U64 endt_us, U64 *exit_code_out)
867867 if (kill (pid , 0 ) >= 0 )
868868 {
869869 result = (errno == ENOENT );
870-
870+
871871 if (result )
872872 {
873873 int status ;
@@ -969,11 +969,7 @@ internal Mutex
969969os_mutex_alloc (void )
970970{
971971 OS_LNX_Entity * entity = os_lnx_entity_alloc (OS_LNX_EntityKind_Mutex );
972- pthread_mutexattr_t attr ;
973- pthread_mutexattr_init (& attr );
974- pthread_mutexattr_settype (& attr , PTHREAD_MUTEX_RECURSIVE );
975- int init_result = pthread_mutex_init (& entity -> mutex_handle , & attr );
976- pthread_mutexattr_destroy (& attr );
972+ int init_result = pthread_mutex_init (& entity -> mutex_handle , 0 );
977973 if (init_result == -1 )
978974 {
979975 os_lnx_entity_release (entity );
@@ -1410,18 +1406,18 @@ lnx_signal_handler(int sig, siginfo_t *info, void *arg)
14101406 sleep (UINT32_MAX );
14111407 }
14121408 }
1413-
1409+
14141410 local_persist void * ips [4096 ];
14151411 int ips_count = backtrace (ips , ArrayCount (ips ));
1416-
1412+
14171413 fprintf (stderr , "A fatal signal was received: %s (%d). The process is terminating.\n" , strsignal (sig ), sig );
14181414 fprintf (stderr , "Create a new issue with this report at %s.\n\n" , BUILD_ISSUES_LINK_STRING_LITERAL );
14191415 fprintf (stderr , "Callstack:\n" );
14201416 for EachIndex (i , ips_count )
14211417 {
14221418 Dl_info info = {0 };
14231419 dladdr (ips [i ], & info );
1424-
1420+
14251421 char cmd [2048 ];
14261422 snprintf (cmd , sizeof (cmd ), "llvm-symbolizer --relative-address -f -e %s %lu" , info .dli_fname , (unsigned long )ips [i ] - (unsigned long )info .dli_fbase );
14271423 FILE * f = popen (cmd , "r" );
@@ -1435,12 +1431,12 @@ lnx_signal_handler(int sig, siginfo_t *info, void *arg)
14351431 String8 module = str8_skip_last_slash (str8_cstring (info .dli_fname ));
14361432 String8 file = str8_skip_last_slash (str8_cstring_capped (file_name , file_name + sizeof (file_name )));
14371433 if (file .size > 0 ) file .size -= 1 ;
1438-
1434+
14391435 B32 no_func = str8_match (func , str8_lit ("??" ), StringMatchFlag_RightSideSloppy );
14401436 B32 no_file = str8_match (file , str8_lit ("??" ), StringMatchFlag_RightSideSloppy );
14411437 if (no_func ) { func = str8_zero (); }
14421438 if (no_file ) { file = str8_zero (); }
1443-
1439+
14441440 fprintf (stderr , "%ld. [0x%016lx] %.*s%s%.*s %.*s\n" , i + 1 , (unsigned long )ips [i ], (int )module .size , module .str , (!no_func || !no_file ) ? ", " : "" , (int )func .size , func .str , (int )file .size , file .str );
14451441 }
14461442 pclose (f );
@@ -1451,7 +1447,7 @@ lnx_signal_handler(int sig, siginfo_t *info, void *arg)
14511447 }
14521448 }
14531449 fprintf (stderr , "\nVersion: %s%s\n\n" , BUILD_VERSION_STRING_LITERAL , BUILD_GIT_HASH_STRING_LITERAL_APPEND );
1454-
1450+
14551451 _exit (0 );
14561452}
14571453
@@ -1470,7 +1466,7 @@ main(int argc, char **argv)
14701466 sigaction (SIGSEGV , & handler , NULL );
14711467 sigaction (SIGQUIT , & handler , NULL );
14721468 }
1473-
1469+
14741470 //- rjf: set up OS layer
14751471 {
14761472 //- rjf: get statically-allocated system/process info
0 commit comments