6

I've created a named pipe on Debian using mkfifo pipe.in. I want to write to this pipe from Matlab.

To do this, I use the following matlab command:

unix( 'cat <myfile> > pipe.in' )

Where <myfile> is a text file and pipe.in is the pipe I created with mkfifo.

In many cases, the process associated to the pipe crashed for many reason (but any reason beyond the use of the unix and cat command). The crash can be normal in several cases.

Executing the above command causes Matlab to freeze, and I can't regain control with CTRL+C.

Is there another way to release Matlab without requiring me to kill the process?

Guuk
  • 199

1 Answers1

2

Unblocking Matlab

You can unblock Matlab by sending the QUIT signal by pressing CTRL-\ in the terminal that you launched Matlab from.

Why Matlab is freezing

Matlab is freezing because the unix function never returns because cat <myfile> > pipe never terminates.

Executing cat <myfile> > pipe.in in a terminal demonstrates the same "freezing" behavior.

My bash-fu isn't very good, but I think that something must be reading from the pipe before the writer can terminate.

Create a temporary pipe and file

mkfifo /tmp/tempPipe
echo "1 2 3 4 5 6 7 8 0" > /tmp/tempFile

Write to the pipe

This command will not terminate:

cat /tmp/tempFile > /tmp/tempPipe 

This command will:

cat /tmp/tempFile > /tmp/tempPipe & cat < /tmp/tempPipe

I expect that if you create a reading process then your Matlab call to unix will terminate.

slayton
  • 121