minit

A small yet feature-complete init (http://fefe.de/minit/)
Log | Files | Refs | README | LICENSE

write_proc.c (354B)


      1 #include <unistd.h>
      2 #include <fcntl.h>
      3 #include <string.h>
      4 
      5 #define USAGE "write_proc <value> <path_to_proc_file>\n"
      6 
      7 int main(int argc,char*argv[]) {
      8   int fd;
      9   if (argc!=3) goto usage;
     10   if ((fd=open(argv[2],O_WRONLY))==-1) goto usage;
     11   write(fd,argv[1],strlen(argv[1]));
     12   close(fd);
     13   return 0;
     14 usage:
     15   write(2,USAGE,strlen(USAGE));
     16   return 1;
     17 }