Path: utzoo!utgpu!watserv1!watmath!att!cbnewsj!dwex From: dwex@cbnewsj.att.com (david.e.wexelblat) Newsgroups: comp.unix.programmer Subject: Re: how to put a program into a .plan file Summary: More trivial in System V Message-ID: <1990Sep28.154733.26346@cbnewsj.att.com> Date: 28 Sep 90 15:47:33 GMT References: <978@bbt.UUCP> <1990Sep26.201406.12663@athena.mit.edu> Organization: AT&T Bell Laboratories Lines: 31 In article <1990Sep26.201406.12663@athena.mit.edu>, jik@athena.mit.edu (Jonathan I. Kamens) writes: > In article <978@bbt.UUCP>, rgs@bbt.UUCP (steinbeiser) writes: > |> Ok, how do you check the status of the file to see if it has > |> been open by someone else? Its not obvious how (or if) stat() would do this. > |> Also, would the C program have to be running constantly in the background > |> someplace? > > 1. You open the pipe for write, and do a select() on it, and when you get an > OK to write from select(), you know that someone has opened the other end. > Or, in System V, quoting from the open(2) man page: When opening a FIFO with O_RDONLY or O_WRONLY set: If O_NDELAY is set: [ not relevant ] If O_NDELAY is clear: An open for reading-only will block until a process opens the file for writing. An open for writing-only will block until a process opens the file for reading. So all you have to do is make .plan a FIFO, and have a program open it for writing (the program will have to be in an infinite loop, though). -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- David Wexelblat | dwex@mtgzx.att.com | They recommended AT&T Bell Laboratories | ...!att!mtgzx!dwex | euthanasia 200 Laurel Ave - 4B-421 | | For nonconformists Middletown, NJ 07748 | (201) 957-5871 | everywhere