tools/testing/selftests/proc/proc-self-wchan.c

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/proc/proc-self-wchan.c
Extension
.c
Size
1163 bytes
Lines
41
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

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>

int main(void)
{
	char buf[64];
	int fd;

	fd = open("/proc/self/wchan", O_RDONLY);
	if (fd == -1) {
		if (errno == ENOENT)
			return 4;
		return 1;
	}

	buf[0] = '\0';
	if (read(fd, buf, sizeof(buf)) != 1)
		return 1;
	if (buf[0] != '0')
		return 1;
	return 0;
}

Annotation

Implementation Notes