File: write_proc.c

package info (click to toggle)
minit 0.10-5
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 224 kB
  • ctags: 139
  • sloc: ansic: 1,655; makefile: 129; sh: 49; python: 33
file content (17 lines) | stat: -rw-r--r-- 354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USAGE "write_proc <value> <path_to_proc_file>\n"

int main(int argc,char*argv[]) {
  int fd;
  if (argc!=3) goto usage;
  if ((fd=open(argv[2],O_WRONLY))==-1) goto usage;
  write(fd,argv[1],strlen(argv[1]));
  close(fd);
  return 0;
usage:
  write(2,USAGE,strlen(USAGE));
  return 1;
}