osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help to debug my free library


Dennis Lee Bieber wrote:

> On Wed, 31 Jan 2018 20:58:56 +0200, Victor Porton <porton at narod.ru>
> declaimed the following:
> 
>>LibComCom is a C library which passes a string as stdin of an OS command
>>and stores its stdout in another string.
>>
>>I wrote this library recently:
>>https://github.com/vporton/libcomcom
>>
>>Complete docs are available at
>>https://vporton.github.io/libcomcom-docs/
>>
>>Now I am trying to make Python bindings to the library:
>>https://github.com/vporton/libcomcom-python
>>
> 
> Debug -- no help, I'm not a fluent Linux programmer...
> 
> But based upon the description of this library, I would have to ask:
> 
> "What does this library provide that isn't already in the Python standard
> library?"
> 
> "Why would I want to use this library instead of, say
> subprocess.Popen().communicate()?" (or the older Popen* family)
> 
> {Though .communicate() is a one-shot call -- sends one packet to
> subprocess' stdin, reads to EOF, and waits for subprocess to terminate. If
> one needs interactive control, one needs explicit write/read calls,
> although those can deadlock if the caller and subprocess aren't written
> for such interaction}

If it "sends one packet", this would lead to a deadlock (even for "cat" 
command). Hopefully, you are wrong here.

I found that Popen.communicate() seems to solve my problem. (Previously I 
programmed in Java and found no native solution. For this reason I created 
my LibComCom.)

-- 
Victor Porton - http://portonvictor.org