Perforce Public Knowledge Base - Trouble-shooting "broken pipe" p4broker errors
Reset Search
 

 

Article

Trouble-shooting "broken pipe" p4broker errors

« Go Back

Information

 
Problem

When using the Perforce broker, a user may encounter a "Broken pipe" error. An example of the broken pipe error, after trying to execute a command, is as follows:

Example

Broker error executing '/home/scripts/editfoo.pl'
write: command: Broken pipe

 

Solution

The System Administrator's Guide mentions the following under the Filter Programs section:

Your filter program must read this data from stdin before performing
any additional processing, regardless of whether the script requires the data.
If the filter script does not read the data from stdin, "broken pipe" errors
can occur, and the broker rejects the user's command.

(This same information is also mentioned in the P4Broker Release Notes under the Filter Programs section.)

 

To trouble-shoot and solve the "Broken pipe" error, check for the following types of issues that could prevent the broker filter script from reading the data from STDIN:

  • Script permission rights

    Check the filter script's permission rights to ensure the script has executable rights.
     

    Example

    The following scenario uses the broken pipe error example from above. Notice the file does not have executable permissions:
    UNIX:
    $ ls -al /home/scripts/editfoo.pl
    -r--r--r-- 1 myuser root 1790 Feb 17 17:25 editfoo.pl
    
    
    To fix that issue, the file permissions are modified to make the file executable:
    
    		
    UNIX:
    $ chmod 755 /home/scripts/editfoo.pl
    
    $ ls -al /home/scripts/editfoo.pl
    -rwxr-xr-x 1 myuser root 1790 Feb 17 17:25 editfoo.pl
    
    
    Now notice what happens when I edit the file which activates the broker filter script.
    
    $ p4 edit foo.h
    PROCEED WITH EDIT!
    //depot/foo.h#1 - opened for edit
    
    
    As opposed to the former behavior which was:
    
    $ p4 edit foo.h
    Broker error executing '/home/scripts/editfoo.pl'
    write: command: Broken pipe
    

     

  • STDIN in the script code

    Check the filter script code to verify if the STDIN data is actually being read or not.


    Example

    Notice the error messages below after two (2) consecutive attempts to edit the file.
     
    $p4 edit foo.h
    Broker error executing '/home/scripts/editfoo.pl'
    write: command: Broken pipe
    
    $ p4 edit foo.h
    Invalid response from broker trigger '/home/scripts/editfoo.pl':
    
            no error message
    
    is not a valid response.
    
    
    
    Notice there is a syntax error where the STDIN is passed into a hash array, when checking the actual code in the editfoo.pl script.
    
    
    my %cmd_info = map { /(.*?):\s*(.*)/; ( $1 $2 ) } < stdin > ;
    
    
    
    To fix this syntax error issue in the code, a comma "," is added in between the variables $1 and $2 in the hash array.
    
    my %cmd_info = map { /(.*?):\s*(.*)/; ( $1, $2 ) } < stdin > ;
    
    
    
    Notice the command now runs and the broker filter PASS message displays.
    
    $ p4 edit foo.h
    PROCEED WITH EDIT!
    //depot/foo.h#1 - opened for edit
    

     

 

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255