Check-in [56afeb8408]
Overview
SHA1:56afeb8408aee2a87174fc2667baafc6f65e37bd
Date: 2017-08-14 22:15:40
User: rkeene
Comment:Added support for setting the thread name (PR_SET_NAME)
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2017-08-14
22:22
[23693dd526] Updated license information (user: rkeene, tags: trunk)
22:15
[56afeb8408] Added support for setting the thread name (PR_SET_NAME) (user: rkeene, tags: trunk)
2017-03-03
21:55
[ccc207b59e] Post-release version increment (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [1bab576540] to [b078389520].

     1      1   #define _LINUX_SOURCE 1
     2      2   #include <sys/resource.h>
     3      3   #include <sys/syscall.h>
     4      4   #include <sys/termios.h>
     5      5   #include <netinet/in.h>
     6      6   #include <sys/reboot.h>
            7  +#include <sys/prctl.h>
     7      8   #include <arpa/inet.h>
     8      9   #include <sys/socket.h>
     9     10   #include <sys/select.h>
    10     11   #include <sys/mount.h>
    11     12   #include <sys/types.h>
    12     13   #include <sys/ioctl.h>
    13     14   #include <sys/time.h>
................................................................................
   927    928   
   928    929   	reboot_ret = reboot(cmd);
   929    930   	if (reboot_ret != 0) {
   930    931   		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));
   931    932   
   932    933   		return(TCL_ERROR);
   933    934   	}
          935  +
          936  +	return(TCL_OK);
          937  +}
          938  +
          939  +static int tuapi_set_thread_name(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
          940  +	char *name;
          941  +
          942  +	if (objc == 2) {
          943  +#ifdef PR_SET_NAME
          944  +		name = Tcl_GetString(objv[1]);
          945  +		prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0);
          946  +#else
          947  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("unsupported", -1));
          948  +		return(TCL_ERROR);
          949  +#endif
          950  +	} else {
          951  +#ifdef PR_GET_NAME
          952  +		name = malloc(17);
          953  +
          954  +		prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0);
          955  +
          956  +		Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
          957  +
          958  +		free(name);
          959  +#else
          960  +		Tcl_SetObjResult(interp, Tcl_NewStringObj("unsupported", -1));
          961  +		return(TCL_ERROR);
          962  +#endif
          963  +	}
   934    964   
   935    965   	return(TCL_OK);
   936    966   }
   937    967   
   938    968   static int tuapi_eject(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
   939    969   	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));
   940    970   
................................................................................
  3221   3251   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::pivot_root", tuapi_pivot_root, NULL, NULL);
  3222   3252   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::kill", tuapi_kill, NULL, NULL);
  3223   3253   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::waitpid", tuapi_waitpid, NULL, NULL);
  3224   3254   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::ps", tuapi_ps, NULL, NULL);
  3225   3255   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::execve", tuapi_execve, NULL, NULL);
  3226   3256   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::rlimit", tuapi_rlimit, NULL, NULL);
  3227   3257   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::reboot", tuapi_reboot, NULL, NULL);
         3258  +	Tcl_CreateObjCommand(interp, "::tuapi::syscall::set_thread_name", tuapi_set_thread_name, NULL, NULL);
  3228   3259   
  3229   3260   	/* Network related commands */
  3230   3261   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::ifconfig", tuapi_ifconfig, NULL, NULL);
  3231   3262   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::route", tuapi_route, NULL, NULL);
  3232   3263   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::brctl", tuapi_brctl, NULL, NULL);
  3233   3264   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::vconfig", tuapi_vconfig, NULL, NULL);
  3234   3265