how to put a program into a .plan file
david.e.wexelblat
dwex at cbnewsj.att.com
Sat Sep 29 01:47:33 AEST 1990
In article <1990Sep26.201406.12663 at athena.mit.edu>, jik at athena.mit.edu (Jonathan I. Kamens) writes:
> In article <978 at bbt.UUCP>, rgs at 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 at 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
More information about the Comp.unix.programmer
mailing list