Release master before shutting down on a terminal on child_exit

If the shell running in a console terminates, frecon shuts down
the terminal and starts a new one.  However, if it holds onto
master during that process, then the init of the new terminal
can sometimes fail.

BUG=chromium:443853
TEST=use ctrl-d on console on link_freon while:
  (a) everything idle
  (b) playing video in a window
  (c) playing full-screen video

Change-Id: I9420cf063d354d33c3fcb434e4f9d12e90d84022
Reviewed-on: https://chromium-review.googlesource.com/236922
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Commit-Queue: David Sodman <dsodman@chromium.org>
Tested-by: David Sodman <dsodman@chromium.org>
Trybot-Ready: David Sodman <dsodman@chromium.org>
diff --git a/input.c b/input.c
index 2188ef7..74dd5cf 100644
--- a/input.c
+++ b/input.c
@@ -523,6 +523,13 @@
 
 		if (term_is_valid(terminal)) {
 			if (term_is_child_done(terminal)) {
+				if (terminal->video) {
+					// necessary in case chrome is playing full screen
+					// video or graphics
+					//TODO: This is still a race with Chrome.  This
+					//needs to be fixed with bug 444209
+					video_setmode(terminal->video);
+				}
 				term_close(terminal);
 				input.terminals[input.current_terminal] = term_init(input.current_terminal);
 				terminal = input.terminals[input.current_terminal];
diff --git a/video.c b/video.c
index 05786cb..e8ce5de 100644
--- a/video.c
+++ b/video.c
@@ -408,6 +408,8 @@
 	if (!video)
 		return;
 
+	video_release(video);
+
 	destroy_dumb.handle = video->buffer_handle;
 	drmIoctl(video->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);