File: socket-tool.c

package info (click to toggle)
lomiri-app-launch 0.1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,924 kB
  • sloc: cpp: 14,112; ansic: 1,769; makefile: 209; sh: 114; xml: 48; python: 40
file content (28 lines) | stat: -rw-r--r-- 467 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int
main (int argc, char * argv[])
{
	const char * fdstr = getenv("MIR_SOCKET");
	if (!fdstr) {
		fprintf(stderr, "No MIR_SOCKET defined\n");
		return 1;
	}

	int fdnum = 0;
	sscanf(fdstr, "fd://%d", &fdnum);
	if (fdnum == 0) {
		fprintf(stderr, "Unable to get FD number\n");
		return 1;
	}

	char inchar;
	while (read(fdnum, &inchar, 1) == 1)
		fwrite(&inchar, 1, 1, stdout);

	close(fdnum);
	return 0;
}