source for tail ?

source for tail ?

Post by John McBray » Sun, 10 Oct 1993 06:05:21



I need to implement the functionality of 'tail -f' in a program, and would
rather not use a system call to invoke /bin/tail.

Where can I find source for /bin/tail that will compile on HP-UX 9.0?  I
tried the BSD source under the following HP ftp site, but it references
'mmap()' which I can only find on SUN OS... not HP !??

hpcsos.col.hp.com /mirrors/.hpib0/NetBSD/NetBSD-current/src/usr.bin/tail

..where is the _real_ HP version??

Thanks;
John
--
-----------------------------------------------------------------------------

Bell-Northern Research | My opinions are mine, all mine ... | Ph:613-763-8213
-----------------------------------------------------------------------------

 
 
 

source for tail ?

Post by Jose Eli » Sun, 10 Oct 1993 21:07:49


: I need to implement the functionality of 'tail -f' in a program, and would
: rather not use a system call to invoke /bin/tail.

: Where can I find source for /bin/tail that will compile on HP-UX 9.0?  I
: tried the BSD source under the following HP ftp site, but it references
: 'mmap()' which I can only find on SUN OS... not HP !??

: hpcsos.col.hp.com /mirrors/.hpib0/NetBSD/NetBSD-current/src/usr.bin/tail

: ..where is the _real_ HP version??

: Thanks;
: John
: --
: -----------------------------------------------------------------------------

: Bell-Northern Research | My opinions are mine, all mine ... | Ph:613-763-8213
: -----------------------------------------------------------------------------

I'm not trying on being a pain, or saying that you have all the
time in the world to do this, but you can write a tail program
in 5 minutes with I'd say 8 lines of code at most.

jose'

 
 
 

source for tail ?

Post by Shriram Krishnamurt » Sun, 10 Oct 1993 21:34:16




>: I need to implement the functionality of 'tail -f' in a program, and would
>: rather not use a system call to invoke /bin/tail.

>I'm not trying on being a pain, or saying that you have all the
>time in the world to do this, but you can write a tail program
>in 5 minutes with I'd say 8 lines of code at most.

Not quite.  (Well, okay, maybe *you* can ...)  He specifically said he
wanted tail -f, which is a little more subtle than a generic tail
would be, since he needs to poll a pipe, in essence.  He probably
wants something more robust than a na"ive approach would generate,
especially since he's embedding it in his application and hence needs
to consider various annoying little return values.
 
 
 

source for tail ?

Post by Jim Qui » Mon, 11 Oct 1993 00:02:17





>>: I need to implement the functionality of 'tail -f' in a program, and would
>>: rather not use a system call to invoke /bin/tail.

>>I'm not trying on being a pain, or saying that you have all the
>>time in the world to do this, but you can write a tail program
>>in 5 minutes with I'd say 8 lines of code at most.

>Not quite.  (Well, okay, maybe *you* can ...)  He specifically said he
>wanted tail -f, which is a little more subtle than a generic tail
>would be, since he needs to poll a pipe, in essence.  He probably
>wants something more robust than a na"ive approach would generate,
>especially since he's embedding it in his application and hence needs
>to consider various annoying little return values.

The real tail implements (-f) behavior at EOF with this exact fragment:

char bin[BUFSIZ];
. . . .
register int n;

fexit()
{
        register int n;
        if (!follow || piped) exit(0);

        for (;;)
        {
                sleep(1)
                while ((n = read (0, bin, BUFSIZ)) > 0)
                        write (1, bin, n);
        }

Quote:}

note that calls to fexit() are only valid when stdin is coming from a disk
file since a blocking read on a pipe, or terminal device (except raw)
do not need special -f behavior.
--
  ___ ___   mail: uunet!phcs!jq     PHCS, Inc. Advanced Technology Group

\_/ (_\/     Fax: (617) 863-8575   pronounced "Throat-Warbler Mangrove".
       )   Voice: (617) 861-5579                          NeXTMail O.K.
 
 
 

1. hairy tail (was Re: tail -f & RAM disk device driver wanted)

-----BEGIN PGP SIGNED MESSAGE-----

Gawain> I have successfully implemented tail -f functionality by
Gawain> detecting file size changes using stat().  If the file size
Gawain> has changed I do whatever I want to do, if it has not changed
Gawain> I just sleep(1).

Gawain> This actually works quite well and is not CPU intensive at all
Gawain> - in fact it seems LESS CPU intensive then whatever "tail -f"
Gawain> is doing!!

Martin> That is all fine and dandy, but you can only read from regular
Martin> files (or maybe pipes as well?) that way. Try to read from a
Martin> character device, and you loose[sic]. (I think that this can make
Martin> quite a lot of sense at times.)

Well the solution is a "hairy" tail (hmm ;-) which checks whether it
is an ordinary file or a device at the start, and has a read-loop of
each type.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQB1AwUBMUbAmedsuUurvcRtAQE6gwMAv+wD6OKTUi3eJjeBqaUxIC/s088z0YDX
Urcbt86L5aRqgmPz8PUqU+59kVkQgEIKp9MI3NzavrgsIF5iX2o0t8R2snpu4G4E
G9roeaMW8u6T03yi+46DdeNEvw62FUq4
=hZjq
-----END PGP SIGNATURE-----
--

APM Ltd., Poseidon House, Castle Park, Cambridge CB3 0RD

2. How do I delete my kde profile ?

3. non-static buffer tail (was Re: `tail' limitation)

4. URL unicode docs

5. "tail" stops tailing?

6. Debian - PHP, Apache, MySQL - Success?

7. tail source file

8. IDE/ATAPI CD found in 2.5, not found in 2.6

9. Where can I find source code for tail

10. Source-code for "tail" utility

11. Heads or Tails? Where do I get source?

12. Can any open source compiler convert C++ source to C source?

13. What percentage of open-source programmers are paid for working on open-source projects?