tools/testing/selftests/proc/proc-self-isnt-kthread.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/proc/proc-self-isnt-kthread.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/proc/proc-self-isnt-kthread.c
Extension
.c
Size
1246 bytes
Lines
38
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#undef NDEBUG
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

int main(void)
{
	int fd = open("/proc/self/status", O_RDONLY);
	assert(fd >= 0);

	char buf[4096];
	ssize_t rv = read(fd, buf, sizeof(buf));
	assert(0 <= rv && rv < sizeof(buf));
	buf[rv] = '\0';

	/* This test is very much not kernel thread. */
	assert(strstr(buf, "Kthread:\t0\n"));

	return 0;
}

Annotation

Implementation Notes