#42: don't read stdin when running in a noninteractive shell ---------------------------------------+--------------------- Reporter: taeuber | Owner: Type: enhancement | Status: open Priority: wish | Component: FFmpeg Version: git | Resolution: Keywords: noninteractive shell stdin | Blocked By: Blocking: | Reproduced: 0 Analyzed: 0 | ---------------------------------------+---------------------
Comment (by taeuber): Replying to [comment:6 michael]: > Replying to [comment:5 taeuber]: > > Hi Michael, > > Hi lars > > > > > > i found the correct solution: > > {{{ > > inline int interactive() > > { > > return isatty(0); > > i wish it was so simple > but isatty is true for a command like > ffmpeg -i abc.avi def.avi & > > and that will then still get stuck without </dev/null In this case we should check for being a foreground process. This is what my first solution does: {{{ int foreground_process() { int fd, foreground; fd = open ("/dev/tty", O_RDONLY); if (fd < 0) return fd; foreground = (tcgetpgrp(fd) == getpgid(0)); close (fd); return foreground; } }}} But this can change during execution. (Control-Z and then bg in bash) Lars -- Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/42#comment:7> FFmpeg <http://ffmpeg.org> FFmpeg issue tracker _______________________________________________ FFmpeg-trac mailing list FFmpeg-trac@avcodec.org http://avcodec.org/mailman/listinfo/ffmpeg-trac