Anonymous avatar Anonymous committed e5172fa

removed debugging stuff, added -b to srw to ring bell on new messages

Comments (0)

Files changed (1)

 #define MAX_OPENFD  4
 #define MAX_WATCH   512
 
-#define DEBUG
-//#undef DEBUG
-
-#ifdef DEBUG
- #define DBG_PRINTF(args...) fprintf(stderr, args)
-#else
- #define DBG_PRINTF(args...) do{}while(0)
-#endif
-
 int evq, init;
 int wins[MAX_WATCH] = {0};
 char paths[MAX_WATCH][PATH_MAX] = {{0}};
-char cmd[CMD_MAX] = "urxvt -title %p -e srw -p %c cw %o %i";
+char cmd[CMD_MAX] = "urxvt -title %p -e srw -b -p %c cw %o %i";
 
 void usage(void)
 {
 	char *t, *cmd_argv[MAX_ARGS] = {NULL};
 	int i;
 
-	if (wins[wd]) {
-		DBG_PRINTF("already running pid: %d on path: %s\n", wins[wd], paths[wd]);
+	if (wins[wd])
 		return;
-	}
 
 	strcpy(cmd_str, cmd); // stupid strtok messing with my strings
 	for (i = 0, t = strtok(cmd_str, " "); i < MAX_ARGS - 1 && t; i++, t = strtok(NULL, " "))
 		execvp(cmd_argv[0], cmd_argv);
 		err(1, "failed on execvp %s", cmd);
 	}
-
-	DBG_PRINTF("starting: ");
-	for (i = 0; cmd_argv[i]; i++)
-		DBG_PRINTF("%s ", cmd_argv[i]);
-	DBG_PRINTF("\n\tpid: %d\n", wins[wd]);
 }
 
 int add_dir(const char *fpath, const struct stat *sb, int typeflag)
 		warn("failed on inotify_add_watch on %s", fpath);
 
 	if (paths[wd][0] == '\0') {
-		DBG_PRINTF("adding dir wd: %d path: %s\n", wd, fpath);
 		strcpy(paths[wd], fpath);
 		sprintf(out, "%s/out", fpath);
 		if (!init && stat(out, &st) == 0)
 	int wd;
 
 	while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
-		if ((wd = find(wins, pid, MAX_WATCH)) > -1) {
-			DBG_PRINTF("reaped pid: %d path: %s\n", pid, paths[wd]);
+		if ((wd = find(wins, pid, MAX_WATCH)) > -1)
 			wins[wd] = 0;
-		}
 	}
 }
 
 	for (;;) {
 		if ((len = read(evq, buf, sizeof(buf))) < 0 && errno != EINTR)
 			warn("failed to read from inotify event queue");
-		DBG_PRINTF("inotify read %d bytes\n", len);
 		for (cur = (struct inotify_event *)buf;
 			 (char *)cur - buf < len;
 			 cur = (struct inotify_event *)((char *)cur + sizeof(struct inotify_event) + cur->len)) {
-			DBG_PRINTF("inotify wd: %d\tpath: %s\tname: %s\n", cur->wd, paths[cur->wd], cur->name);
 			if (cur->mask & (IN_CREATE | IN_ISDIR))
 				ftw(root, add_dir, MAX_OPENFD);
 			if (cur->mask & (IN_CREATE | IN_MODIFY) && !strcmp(cur->name, "out"))
 				win(cur->wd);
 		}
-		DBG_PRINTF("done with that read\n\n\n");
 	}
 
 	return 0;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.