Index: tuapi.c ================================================================== --- tuapi.c +++ tuapi.c @@ -2,10 +2,11 @@ #include #include #include #include #include +#include #include #include #include #include #include @@ -929,10 +930,39 @@ if (reboot_ret != 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1)); return(TCL_ERROR); } + + return(TCL_OK); +} + +static int tuapi_set_thread_name(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + char *name; + + if (objc == 2) { +#ifdef PR_SET_NAME + name = Tcl_GetString(objv[1]); + prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0); +#else + Tcl_SetObjResult(interp, Tcl_NewStringObj("unsupported", -1)); + return(TCL_ERROR); +#endif + } else { +#ifdef PR_GET_NAME + name = malloc(17); + + prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0); + + Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1)); + + free(name); +#else + Tcl_SetObjResult(interp, Tcl_NewStringObj("unsupported", -1)); + return(TCL_ERROR); +#endif + } return(TCL_OK); } static int tuapi_eject(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { @@ -3223,10 +3253,11 @@ Tcl_CreateObjCommand(interp, "::tuapi::syscall::waitpid", tuapi_waitpid, NULL, NULL); Tcl_CreateObjCommand(interp, "::tuapi::syscall::ps", tuapi_ps, NULL, NULL); Tcl_CreateObjCommand(interp, "::tuapi::syscall::execve", tuapi_execve, NULL, NULL); Tcl_CreateObjCommand(interp, "::tuapi::syscall::rlimit", tuapi_rlimit, NULL, NULL); Tcl_CreateObjCommand(interp, "::tuapi::syscall::reboot", tuapi_reboot, NULL, NULL); + Tcl_CreateObjCommand(interp, "::tuapi::syscall::set_thread_name", tuapi_set_thread_name, NULL, NULL); /* Network related commands */ Tcl_CreateObjCommand(interp, "::tuapi::syscall::ifconfig", tuapi_ifconfig, NULL, NULL); Tcl_CreateObjCommand(interp, "::tuapi::syscall::route", tuapi_route, NULL, NULL); Tcl_CreateObjCommand(interp, "::tuapi::syscall::brctl", tuapi_brctl, NULL, NULL);