Date: Sat, 29 Jan 94 02:07:35 JST From: Stephen Turnbull To: brssp2!twuyts AT brgtw DOT att DOT com Cc: bergman AT panix DOT com, djgpp AT sun DOT soe DOT clarkson DOT edu Subject: fseek / share I'm not an expert on DOS and SHARE, but could somebody explain how it exactly works ? What's the effect of the unlink when SHARE is running ? I'm no expert either, but here goes... Basically, share sets up some kind of semaphore that prevents processes that don't own a file from doing dangerous things to it. I don't know quite what groff is doing, but I assume it's creating a temporary file of some kind. This kind of behavior is fine under Unix, because under Unix temporary files are a system resource. (I'm not sure if this is technically true, but there are utility functions for handling them, at least for getting tmpfile names. In fact, groff may use the unlink to completely hide the tmpfile from any other process. This would depend on Unix not touching any of the file's resources, like the inode, until it's closed. This seems reasonable to me.) But under DOS, temporary files are not different in any way from ordinary files; and worse, DOS *keeps the file's allocation information in the directory entry*, not in a separte resource like an inode under Unix. This means that there are two bad things that can happen if groff is allowed to unlink the file. One is that other programs could do the same thing. Well actually, the problem is that the *same* program in a different process could do it. This is typical of DOS programs which typically call their tmpfiles "tmpfile": and the second copy of such a program would then go overwrite it! Worse yet, if groff were allowed to unlink the file, then the directory entry would be indicated as deleted, and very probably the next file opened would reuse that space. This is a good way to fill up your disk with "lost chains." This is one of many reasons why DOS Windows can't do real multitasking very well. it is made by Martin Filteau (fm59 AT music DOT mus DOT polymtl DOT ca) and fools any program that needs share into beleiving it is running (such as Word 6). I don't know what the possible dangers are, but it works for me. See above. As long as you only run one copy of each program you should be in good shape. Just pray that none of your other programs running in the background ever open a file using the space in the directory that groff's tmpfile uses. --Steve