Date: Sat, 6 Apr 1996 17:16:20 +1000 From: Bruce Evans <bde@zeta.org.au> To: hackers@FreeBSD.org, jkh@time.cdrom.com Subject: Re: Any clues as to why this fails? Message-ID: <199604060716.RAA14868@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>#include <signal.h> >#include <fcntl.h> >void >handler(int sig) >{ > printf("Signal %d received\n", sig); >} >main() >{ > int i, fd; > signal(SIGIO, handler); > fd = open("/dev/cuaa1", O_RDONLY | O_NONBLOCK | O_EXCL); > printf("%d\n", fd); > i = fcntl(fd, F_GETFL, 0); > printf("%d\n", i); > printf("%d\n", fcntl(fd, F_SETFL, i | O_ASYNC)); > printf("%d\n", fcntl(fd, F_SETOWN, getpid())); /* This call returns -1 */ > pause(); >} >I've read the man page for fcntl() and it really appears as though >that F_SETOWN call should work. Any clues as to why not? This F_SETOWN on a tty only works for controlling terminals. This is because F_SETOWN is implemented as tcsetpgrp() and tcsetpgrp() is specified by POSIX. To work like you want, F_SETOWN would need a separate pgrp entries in the tty struct. Sockets work like you want because there is no POSIX pgrp entry to conflict with. F_SETOWN doesn't work on anything except ttys, sockets or perhaps pipes. To work as documented in fcntl.3, F_SETOWN would need to have a pgrp entry in the filedesc struct. This would probably be useful - it would allow sending SIGIO to arbitrary sets of sufficiently privileged processes. The test program has many bugs. - <sys/types.h> isn't included. - printf() gives undefined behaviour in signal handlers. ... Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604060716.RAA14868>