File: puts_proc_self_exe.c

package info (click to toggle)
proot 5.1.0-1.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, trixie
  • size: 2,228 kB
  • sloc: ansic: 16,491; sh: 1,327; asm: 41; makefile: 8
file content (18 lines) | stat: -rw-r--r-- 315 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <unistd.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
	char path[PATH_MAX];
	ssize_t status;

	status = readlink("/proc/self/exe", path, PATH_MAX - 1);
	if (status < 0 || status >= PATH_MAX)
		exit(EXIT_FAILURE);
	path[status] = '\0';

	puts(path);
	exit(EXIT_SUCCESS);
}