Comment 15 for bug 1849753

Revision history for this message
MichaƂ Sawicz (saviq) wrote :

I just had a similar problem trying to call a confined app from a classic one in Python:

subprocess.run("command", stdin=open("/file/path", "rb"))

The way around it is either reading the file into memory and feeding it in:

subprocess.run("command", input=open("/file/path", "rb").read())

Or looping over the file and writing to the process's stdin:

with subprocess.Popen("command", stdin=subprocess.PIPE) as p, \
     open("/file/path", "rb") as f:
    while True:
        buf = f.read(8192)
        if buf:
            p.stdin.write(buf)
        else:
            break