--- busybox-1.21.0/init/init.c	2013-01-14 18:04:27.000000000 +0100
+++ src/init/init.c	2017-12-22 13:38:02.641259350 +0100
@@ -201,6 +201,7 @@
 static struct init_action *init_action_list = NULL;
 
 static const char *log_console = VC_5;
+static bool console_is_tty;
 
 enum {
 	L_LOG = 0x1,
@@ -577,6 +578,9 @@
 		if (!(a->action_type & action_type))
 			continue;
 
+		if ((a->action_type & ASKFIRST) && !a->terminal[0] && !console_is_tty)
+			continue;
+
 		if (a->action_type & (SYSINIT | WAIT | ONCE | CTRLALTDEL | SHUTDOWN)) {
 			pid_t pid = run(a);
 			if (a->action_type & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN))
@@ -998,6 +1002,8 @@
 int init_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int init_main(int argc UNUSED_PARAM, char **argv)
 {
+	struct termios tty;
+
 	if (argv[1] && strcmp(argv[1], "-q") == 0) {
 		return kill(1, SIGHUP);
 	}
@@ -1040,6 +1046,7 @@
 
 	/* Figure out where the default console should be */
 	console_init();
+	console_is_tty = (tcgetattr(STDIN_FILENO, &tty) >= 0);
 	set_sane_term();
 	xchdir("/");
 	setsid();
