There is a project from the pile [*] of someone else's code, in which it would be good to calculate the moments of creating certain files. Looking at the sources, working with the debugger, logs, etc. is complicated by the fact that part of the project runs under the FGCI, part - in the form of demons, and the interaction of all components is not always transparent. In addition, the files that need to be tracked are not regular (everything is clear with them), but temporary / service ones, and those created are not so predictable.

The first thought was to use File :: Monitor , but it immediately self-destructed for obvious reasons (you can hang up scan() with quite informative callbacks asynchronously, but you can't track where the file was created).

The second solution, put together in a hurry, is no less obvious (only open used there, so that is enough):

 sub my_open( *;$@ ) { # сохраняем стек callers, аргументы # и вызываем CORE::open } BEGIN { *CORE::GLOBAL::open = \&my_open; } 

The output is the following records, 1 for each open call:

 TRACE_OPEN(">","/tmp/0.638145504593016.$$$"): from W::abc() from X::bar() from Y::new() from Z::foo() 

In principle, it still suits, but is it possible to be more elegant? The output should be the same or similar.

[*] In fact, not so deadly much, but ...

 $ cloc . --match-f='[.]p[ml]$' 156 text files. 156 unique files. 55 files ignored. http://cloc.sourceforge.net v 1.60 T=7.96 s (19.6 files/s, 10802.5 lines/s) ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- Perl 192 18663 6092 64518 ------------------------------------------------------------------------------- 
  • inotify? strace with correct flags - strangeqargo
  • @strangeqargo, inotify will not work for exactly the same reasons as File :: Monitor (and it does the same thing). And about strace can be more detailed? What exactly need to get now I will add to the question. - PinkTux
  • here I would look, linux-audit.com/the-ultimate-strace-cheat-sheet - strangeqargo
  • @strangeqargo, you can be more precise - where is the trace of the pearl-barley source? (I suggest: nowhere ...) - PinkTux
  • he will catch all the calls to the FS, that's what I'm talking about, although, of course, you can screw it to the pearl ... well, as an option, you can get it right into the pearl code and rebuild

0