Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-10

Prevent from deadlock while writing something large to a pipe

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Kiên Nguyễn Tiến Trung

I want to send a big amount of data to a child process through pipe. However, it is stated in the documentation that writing too much into the pipe may cause a deadlock.
TProcess.Input

Input is a stream which is connected to the process' standard input file handle. Anything written to this stream can be read by the process.

The Input stream is only instantiated when the poUsePipes flag is used in Options
<http://lazarus-ccr.sourceforge.net/docs/fcl/process/tprocess.options.html>.

Note that writing to the stream may cause the calling process to be suspended when the created process is not reading from it's input, or to cause errors when the process has terminated.

How can I prevent from deadlock?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151009/426ca84e/attachment.html>

Reply by email

Sven Barth
to Kiên Nguyễn Tiến Trung
"Ki?n Nguy?n Ti?n Trung" wrote
I want to send a big amount of data to a child process through pipe.

However, it is stated in the documentation that writing too much into the pipe may cause a deadlock.

That is not necessarily a deadlock. It just blocks until the receiving profess is ready to process more input. Of course you should process it's output, cause if it can't write into its output anymore it can't normally read from its input either ;)
That said you could write into the Input in a separate thread, this way your GUI stays responsive.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151009/e647d75b/attachment.html>

Reply by email

Kiên Nguyễn Tiến Trung
to Sven Barth

Thank you. I will try again with multi threading.

2015-10-09 22:10 GMT+07:00 Sven Barth :

Show quoted text 23 lines
Am 09.10.2015 16:37 schrieb "Ki?n Nguy?n Ti?n Trung" : > > I want to send a big amount of data to a child process through pipe. However, it is stated in the documentation that writing too much into the pipe may cause a deadlock. That is not necessarily a deadlock. It just blocks until the receiving profess is ready to process more input. Of course you should process it's output, cause if it can't write into its output anymore it can't normally read from its input either ;) That said you could write into the Input in a separate thread, this way your GUI stays responsive. Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151009/c0f8030a/attachment.html>

Reply by email