On Tue, 14 Jun 2011 14:19:07 -0700 Brian Ginn wrote: > Rather than forcing my program to the foreground, my program wants to know > whether it was executed in the background with &, or whether it is in the > foreground.
> I am testing tcgetpgrp(fileno(stdin) against getpgid(getpid()). If they are > different, my program avoids calling tcgetattr() and tcsetattr(), thus > avoiding an unnecessary SIGTTOU if terminal I/O is not needed. > Is there a better way to determine if a program is running in the background? > Also, it looks like SUSv3 posix_spawn() can set the process group: > If the POSIX_SPAWN_SETPGROUP flag is set in the spawn-flags attribute of the > object referenced by attrp, and the spawn-pgroup attribute of the same object > is non-zero, then the child's process group shall be as specified in the > spawn-pgroup attribute of the object referenced by attrp. > As a special case, if the POSIX_SPAWN_SETPGROUP flag is set in the > spawn-flags attribute of the object referenced by attrp, and the spawn-pgroup > attribute of the same object is set to zero, then the child shall be in a new > process group with a process group ID equal to its process ID. > If the POSIX_SPAWN_SETPGROUP flag is not set in the spawn-flags attribute of > the object referenced by attrp, the new child process shall inherit the > parent's process group. the ast spwanveg() when iffe'd for posix_spawn() uses POSIX_SPAWN_SETPGROUP this doesn't help with tcsetattr() however since process group != terminal group _______________________________________________ ast-developers mailing list ast-developers@research.att.com https://mailman.research.att.com/mailman/listinfo/ast-developers