Evan Gates  committed 9346a06

add -l for late start

  • Participants
  • Parent commits 8524b10

Comments (0)

Files changed (2)

 .SY srw
+.OP \-l
 .OP \-p prompt
 .OP \-v
 .OP \-w
 .IR args...
 the arguments passed to cmd
+.B \-l
+wait one second for each -l before starting the child (useful if child needs to know terminal size)
 .BI \-p " prompt"
 override the default prompt (>)
 and not shortcuts:
 .I C-l
-send SIGWINCH to child process group (helpful for cw)
+clear screen and send SIGWINCH to child process group (helpful for cw)
 .I C-v
 enter next character typed, for example ^V^D inserts a ^D instead of deleting a character
 void usage(void)
-	printf("Usage: srw [-p prompt] [-v] [-w] cmd [args]...\n");
+	printf("Usage: srw [-l] [-p prompt] [-v] [-w] cmd [args]...\n");
 int main(int argc, char **argv)
-	int i;
+	int i, late_start = 0;
 	for (i = 1; i < argc; i++) {
 		if (argv[i][0] != '-')
 			case 'p' : nrml_prompt = argv[++i]; break;
 			case 'v' : printf("srw-"VERSION" © Evan Gates\n"); exit(1);
 			case 'w' : winch = 1; break;
+			case 'l' : late_start++; break;
 			default  : usage();
 	if (ioctl(STDOUT, TIOCGWINSZ, &ws) < 0)
 		err(1, "failed ioctl");
+	if (late_start)
+		sleep(late_start);
 	if ((child = forkpty(&mfd, NULL, &set, &ws)) == 0) { //child
 		execvp(argv[i], &argv[i]);
 		err(1, "failed execvp %s", argv[i]);
 		if (signal(sig_table[i].sig, sig_table[i].func) == SIG_ERR)
 			err(1, "failed to install %s handler", sig_table[i].name);
+	sigwinch(0);