mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
Redirect only de-/encoder screen output to /dev/null with -q, and restore
standard error outside that popen() call. git-svn-id: https://svn.xiph.org/trunk/ezstream@12596 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
6cdaac888d
commit
ca6161358d
@ -506,10 +506,27 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||
*popenFlag = 0;
|
||||
if (pezConfig->reencode) {
|
||||
if (strlen(extension) > 0) {
|
||||
int stderr_fd = dup(STDERR_FILENO);
|
||||
|
||||
pCommandString = buildCommandString(extension, fileName, pMetadata);
|
||||
if (vFlag > 1)
|
||||
printf("%s: Running command `%s`\n", __progname,
|
||||
pCommandString);
|
||||
|
||||
if (qFlag) {
|
||||
int fd;
|
||||
|
||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
||||
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
||||
__progname, _PATH_DEVNULL, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dup2(fd, STDERR_FILENO);
|
||||
if (fd > 2)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
fflush(NULL);
|
||||
errno = 0;
|
||||
if ((filep = popen(pCommandString, "r")) == NULL) {
|
||||
@ -527,6 +544,9 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
||||
#endif
|
||||
}
|
||||
xfree(pCommandString);
|
||||
|
||||
if (qFlag)
|
||||
dup2(stderr_fd, STDERR_FILENO);
|
||||
} else
|
||||
printf("%s: Error: Cannot determine file type of '%s'.\n",
|
||||
__progname, fileName);
|
||||
@ -1085,20 +1105,6 @@ main(int argc, char *argv[])
|
||||
}
|
||||
#endif /* HAVE_SIGNALS */
|
||||
|
||||
if (qFlag) {
|
||||
int fd;
|
||||
|
||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
||||
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
||||
__progname, _PATH_DEVNULL, strerror(errno));
|
||||
return (1);
|
||||
}
|
||||
|
||||
dup2(fd, STDERR_FILENO);
|
||||
if (fd > 2)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
||||
int ret;
|
||||
char *tmpFileName, *p;
|
||||
|
Loading…
Reference in New Issue
Block a user