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
2
3
4
5
6

7
8
9
10
11
12
13
...
927
928
929
930
931
932
933





























934
935
936
937
938
939
940
....
3221
3222
3223
3224
3225
3226
3227

3228
3229
3230
3231
3232
3233
3234
#define _LINUX_SOURCE 1
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/termios.h>
#include <netinet/in.h>
#include <sys/reboot.h>

#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
................................................................................

	reboot_ret = reboot(cmd);
	if (reboot_ret != 0) {
		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));

		return(TCL_ERROR);
	}






























	return(TCL_OK);
}

static int tuapi_eject(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));

................................................................................
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::pivot_root", tuapi_pivot_root, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::kill", tuapi_kill, NULL, NULL);
	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);


	/* 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);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::vconfig", tuapi_vconfig, NULL, NULL);







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
....
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
#define _LINUX_SOURCE 1
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/termios.h>
#include <netinet/in.h>
#include <sys/reboot.h>
#include <sys/prctl.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
................................................................................

	reboot_ret = reboot(cmd);
	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[]) {
	Tcl_SetObjResult(interp, Tcl_NewStringObj("not implemented", -1));

................................................................................
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::pivot_root", tuapi_pivot_root, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::kill", tuapi_kill, NULL, NULL);
	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);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::vconfig", tuapi_vconfig, NULL, NULL);