+void do_display_screen(struct usb_dev_handle *sc)
+{
+ unsigned char *png;
+ int imglen;
+ int ret;
+ int pipefd[2];
+ pid_t display;
+
+ png = get_lcd(sc, &imglen);
+ if (png == NULL) {
+ perror("get_lcd");
+ return;
+ }
+
+ if (pipe(pipefd) == -1) {
+ perror("pipe");
+ return;
+ }
+
+ display = fork();
+ switch(display) {
+ case 0:
+ close(pipefd[1]);
+ close(STDIN_FILENO);
+ dup2(pipefd[0], STDIN_FILENO);
+ execlp("display", "display", "-", NULL);
+ exit(0);
+ break;
+ case -1:
+ perror("fork");
+ break;
+ default:
+ close(pipefd[0]);
+ while(imglen > 0) {
+ ret = write(pipefd[1], png, imglen);
+ if (ret == -1) {
+ perror("write");
+ exit(EXIT_FAILURE);
+ }
+ imglen -= ret;
+ }
+ close(pipefd[1]);
+ break;
+ }
+}
+