st-flexipatch

My st-flexipatch configuration
git clone git://git.ethandl.dev/st-flexipatch
Log | Files | Refs | README | LICENSE

rightclicktoplumb_x.c (344B)


      1 #include <sys/wait.h>
      2 
      3 void
      4 plumb(char *sel)
      5 {
      6 	if (sel == NULL)
      7 		return;
      8 
      9 	char cwd[PATH_MAX];
     10 	pid_t child;
     11 
     12 	if (subprocwd(cwd) != 0)
     13 		return;
     14 
     15 	switch (child = fork()) {
     16 		case -1:
     17 			return;
     18 		case 0:
     19 			if (chdir(cwd) != 0)
     20 				exit(1);
     21 			if (execvp(plumb_cmd, (char *const []){plumb_cmd, sel, 0}) == -1)
     22 				exit(1);
     23 			exit(0);
     24 	}
     25 }