diff options
author | Eduardo Chappa <chappa@washington.edu> | 2020-04-11 22:28:56 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2020-04-11 22:28:56 -0600 |
commit | 47206e18c8eec0c9c284cb71381ae85ce36b2a3a (patch) | |
tree | 9bd54b6d44a20deba364bce077059072f898b804 /alpine/osdep | |
parent | b50297779a4becb9ceca9c6b5b375d526fe3df78 (diff) | |
download | alpine-47206e18c8eec0c9c284cb71381ae85ce36b2a3a.tar.xz |
* Remove sleep of 5 seconds for mailcap programs that use the terminal
to display content. Suggested by Carl Edquist. In addition to remove
configurable process table command and it corresponding sleep time.
Diffstat (limited to 'alpine/osdep')
-rw-r--r-- | alpine/osdep/execview.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/alpine/osdep/execview.c b/alpine/osdep/execview.c index eb16e6f8..56730667 100644 --- a/alpine/osdep/execview.c +++ b/alpine/osdep/execview.c @@ -194,12 +194,17 @@ exec_mailcap_cmd(MCAP_CMD_S *mc_cmd, char *image_file, int needsterminal) char *cmd = mc_cmd->command; size_t l; - l = 32 + strlen(cmd) + (2*strlen(image_file)); + /* 32 is enough to contain "( ; sleep 5 ; rm -f ) &\n\0" */ + l = 32 + strlen(cmd) + strlen(image_file); p = command = (char *) fs_get((l+1) * sizeof(char)); - if(!needsterminal) /* put in background if it doesn't need terminal */ + + if(needsterminal) + snprintf(p, l+1-(p-command), "%s ; rm -f %s", cmd, image_file); + else{ *p++ = '('; + snprintf(p, l+1-(p-command), "%s ; sleep 5 ; rm -f %s", cmd, image_file); + } - snprintf(p, l+1-(p-command), "%s", cmd); p += strlen(p); if(!needsterminal){ if(p-command+2 < l+1){ @@ -246,7 +251,7 @@ exec_mailcap_cmd(MCAP_CMD_S *mc_cmd, char *image_file, int needsterminal) #else char *command = NULL, *result_file = NULL, - *p, *cmd, *q, *psef; + *p, *cmd; char **r_file_h; PIPE_S *syspipe; int mode; @@ -258,23 +263,17 @@ exec_mailcap_cmd(MCAP_CMD_S *mc_cmd, char *image_file, int needsterminal) else return; -#ifdef PSEFCMD - psef = fs_get((60 + strlen(PSEFCMD) + strlen(image_file))*sizeof(char)); - sprintf(psef, "PSEF=`%s | /bin/grep \"%s\" | /bin/grep -v grep`", PSEFCMD, image_file); - - q = fs_get((80 + 2*strlen(psef))*sizeof(char)); /* bigger than 62 */ - sprintf(q, "/bin/sh -c '(%s; while test -n \"$PSEF\" ; do %s ; sleep %d ; done)' ;", psef, psef, ps_global->sleep); - fs_give((void **) &psef); -#else - q = cpystr(""); -#endif /* PSEFCMD */ - - l = 45 + strlen(cmd) + 2*strlen(image_file) + strlen(q); + /* 32 is enough for "( ; sleep 5; rm -f ) &\n\0" */ + l = 32 + strlen(cmd) + strlen(image_file); p = command = (char *)fs_get((l+1) * sizeof(char)); - if(!needsterminal) /* put in background if it doesn't need terminal */ + + if(needsterminal) + snprintf(p, l+1-(p-command), "%s ; rm -f %s", cmd, image_file); + else { *p++ = '('; - snprintf(p, l+1-(p-command), "%s ; %s sleep 5 ; rm -f %s", cmd, q, image_file); - fs_give((void **)&q); + snprintf(p, l+1-(p-command), "%s ; sleep 5 ; rm -f %s", cmd, image_file); + } + command[l] = '\0'; p += strlen(p); if(!needsterminal && (p-command)+5 < l){ |