Go Back   Armenian Knowledge Base > Technical sections > Software > Software Security

Reply
 
Thread Tools

Monitoring fopen()/fprintf()
Old 29.11.2004, 13:15   #1
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 40
Posts: 379
Rep Power: 0
Default Monitoring fopen()/fprintf()

Question to GURUs :

How to monitor fopen()/fprintf().

OS - RedHat 7.3 (2.4.20-18.7.cern)

Give some hints, please.


P.S. I am already looking through coreutils sources (to find out how 'tail -f' is implemented).
__________________
Free your mind and your OS will follow

Old 29.11.2004, 13:23   #2
Главный Лысый
 
Pascal's Avatar
 
Join Date: 10 2001
Location: AM
Age: 47
Posts: 2,829
Rep Power: 5
Default

lsof - pomozhet dlya fopen - a.
__________________
Ruben Muradyan
Technical Director
PanARMENIAN Network: Armenian News

----------------------------------------------------
Лысина - это полянка, вытоптанная мыслями.
----------------------------------------------------

Old 29.11.2004, 18:15   #3
Честный Кот
 
Reckon_'s Avatar
 
Join Date: 04 2004
Location: Yerevan
Age: 49
Posts: 1,844
Rep Power: 5
Default

В принципе можно даже использовать strace.

Беда лишь в том, что fopen/fprintf не являются непосредственно системными вызовами (fopen() вызывает в свою очередь open(), а fprintf() вызывает
write(), кажется).

Но, зная этот факт, можно сделать так:

strace -p <pid> -e trace=open,write

где <pid> - номер исследуемого процесса.


Quote:
P.S. I am already looking through coreutils sources (to find out how 'tail -f' is implemented).
Читаем мануал по tail:

.......................................

With --follow (-f), tail defaults to following the file descriptor,
which means that even if a tail'ed file is renamed, tail will continue
to track its end. This default behavior is not desirable when you
really want to track the actual name of the file, not the file descrip-
tor (e.g., log rotation). Use --follow=name in that case. That causes
tail to track the named file by reopening it periodically to see if it
has been removed and recreated by some other program.

.........................................

Короче говоря: tail использует механизм тайм-аутов, и проверяет статус файла через определенный период времени. Просто и эффективно. И tail не attach-ается к какому-либо процессу (как деляет strace), и не лезет в ядро. Так что перехватывать вызовы чтобы понять, как устроен tail - нет резона.
__________________
Честный Кот
------------------------------------------------------
Еще не жаль огня, и Бог хранит меня... (с) А. Макаревич

Когда я трезв, я - Муму и Герасим, мама;
А так я - Война и Мир. (c) БГ

Last edited by Reckon_; 29.11.2004 at 18:49.

Old 30.11.2004, 12:47   #4
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 40
Posts: 379
Rep Power: 0
Default

2 Pascal: Spasibo


2 Reckon_: Tebe toje spasibo

Quote:
Originally Posted by Reckon_
Так что перехватывать вызовы чтобы понять, как устроен tail - нет резона.
Ya i ne sobiralsya perxvativat' vizov dlya togo chtobi ponyat' kak tail rabotatet. Mne isxodniki ego bili nujni dlya togo chtob ponyat' kak on sam rabotatet.
__________________
Free your mind and your OS will follow
Reply




Реклама:
реклама
Buy text link .

All times are GMT. The time now is 00:28.
Top

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.