Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7435361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:03:42+00:00 2026-05-29T10:03:42+00:00

I’m have some php code: <? $cmd=mkfifo /tmp/myfifo;; system($cmd); $cmd=echo 1 > /tmp/myfifo 2>&1

  • 0

I’m have some php code:

<?
$cmd="mkfifo /tmp/myfifo;";
system($cmd);
$cmd="echo 1 > /tmp/myfifo 2>&1 &";
system($cmd);
?>

on an apache server. I want to have the second command not block. According to the info page of system:

If a program is started with this function, in order for it to continue running 
in the background, the output of the program must be redirected to a file or 
another output stream. Failing to do so will cause PHP to hang until the execution 
of the program ends.

But I don’t see how to apply that to this situation. I tried

$cmd="echo 1 > /tmp/myfifo > /dev/null 2>&1 &";

But to be honest that seems nonsensical.

EDIT:

My ultimate goal is to write to a fifo that may never be read from, and time out the write after 5 seconds. So, if I can manage to get this command to not block the php executition, I can sleep 5 seconds and then cat /tmp/myfifo > /dev/null 2>&1 to unblock the original write.

Can anyone think of a better way to have my write not hang indefinitely (in neither the background nor the foreground)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:03:43+00:00Added an answer on May 29, 2026 at 10:03 am

    If you need to write to a file (and prevent other processes from writing until you are done), then just use file_put_contents.

    <?php
    // The new person to add to the file
    $person = "John Smith\n";
    
    // Write the contents to the file, 
    // using the FILE_APPEND flag to append the content to the end of the file
    // and the LOCK_EX flag to prevent anyone else writing to the file at the same time
    file_put_contents('/tmp/myfifo', $person, FILE_APPEND | LOCK_EX);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.