1. Evan Gates
  2. srw


Evan Gates  committed 180bb86

added -w for sigwinch handling

  • Participants
  • Parent commits f500adc
  • Branches default

Comments (0)

Files changed (2)

File srw.1

View file
  • Ignore whitespace
 .SY srw
 .OP \-p prompt
 .OP \-v
+.OP \-w
 .I cmd
 .RI [ args... ]
 .B \-v
 print version information and exit
+.B \-w
+for each SIGWINCH received (window resize), clear screen and send SIGWINCH to the child process group
 srw supports the usual arrow keys, Home, End, Delete, as well as the following shortcuts

File srw.c

View file
  • Ignore whitespace
 void usage(void)
-	printf("Usage: srw [-p prompt] cmd [args]...\n");
+	printf("Usage: srw [-p prompt] [-w] cmd [args]...\n");
+void sigwinch(int unused)
+	cursor_org();
+	cursor_clr();
+	fflush(stdout);
+	kill(-child, SIGWINCH);
 void sigchld(int unused)
 	pid_t pid;
 		switch (argv[i][1]) {
 			case 'p' : nrml_prompt = argv[++i]; break;
 			case 'v' : printf("srw-"VERSION" © Evan Gates\n"); exit(1);
+			case 'w' : if (signal(SIGWINCH, sigwinch) == SIG_ERR)
+						   err(1, "failed to install SIGWINCH handler");
+					   break;
 			default  : usage();