Solved

Linux mkfifo

Posted on 2009-04-08
8
1,096 Views
Last Modified: 2012-05-06
I need to create a buffered fifo named pipe in linux.

I mean something like mkfifo but buffered. My needing is to avoid the writing process to wait for reading process.

Can it be done in Linux?

0
Comment
Question by:phoenix128
  • 3
  • 3
  • 2
8 Comments
 
LVL 77

Expert Comment

by:arnold
ID: 24098418
What is it you are trying to do?

You have to use Event handler on the writer to check whether there is data in the pipe and sleep or do something else.

I think a buffer would do exactly what you claim you do not want and could cause/lead to other problems.
http://modemhelp.net/faqs/fifo.shtml
 
0
 

Author Comment

by:phoenix128
ID: 24098548
I'm writing an application that reads a log file from another software and process it in realtime.

The problem is that my process can be slow sometimes and if I use a traditional fifo I will slow down the other software too.

I was thinking to something like a buffered fifo, but maybe there is even a better solution... any idea will be appreciated.
0
 
LVL 7

Expert Comment

by:Morne Lategan
ID: 24098637
how about perl's tail extension:

http://search.cpan.org/~mgrabnar/File-Tail-0.99.3/Tail.pm

or from bash:

tail -f /var/log/your.log | yourapp
0
 

Author Comment

by:phoenix128
ID: 24098711
tail is what I did last time, the problem is that I am using a tmpfs and allowing the master program to write a real file will expose me to size problems.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 77

Accepted Solution

by:
arnold earned 500 total points
ID: 24098786
I am not sure how your application reading a log file will slow down the other "software" What other software?

How does your application access the log file? Does it start when the system boots and attaches to the file periodically does fseek to the next line etc.?
Or does your application starts based on a cron.  Attaches to the file checks what's there and exits?

In either case you have to add logic to handle log rotation.
I.e. last time you ran, the file was 500 lines. Now your process runs and the file is 200 lines long.  This would mean that the log file rotated which means you need to make sure that you processed all the data from the old file before starting with the new file.  This is easily done through maintaining information the files that exist in the directory location where the log files are stored.

File rotation is the way to get all the information you need while limiting the amount of storage used.  The only drawback is that you have to make sure that your processing of the log file is not longer than the full rotation cycle.
I.e. you allow for five file rotation before the first file is deleted.
Your application has to be done with the processing of the first file before that file has reached its end point on the rotation schedule.


0
 
LVL 7

Expert Comment

by:Morne Lategan
ID: 24098799
Hmm, here's a strange suggestion which but how you make your app exit after 100 lines, and then do this:

#!/bin/bash

while
  :
do
  tail -f /var/log/your.log | yourapp
  rm /var/log/your.log
done

0
 
LVL 7

Expert Comment

by:Morne Lategan
ID: 24098870
No wait that strange suggestion will cause problems in the app that writes the log. Scratch that please.
0
 

Author Closing Comment

by:phoenix128
ID: 31568087
At the end it seems the only way :)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Secure VPN Connection terminated locally by the Client.  Reason 442: Failed to enable Virtual Adapter. If you receive this error on Windows 8 or Windows 8.1 while trying to connect with the Cisco VPN Client then the solution is a simple registry f…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now