libimobiledevice / libusbmuxd

A client library to multiplex connections from and to iOS devices
https://libimobiledevice.org
GNU Lesser General Public License v2.1
574 stars 270 forks source link

iproxy stdout not triggering data event in child process #103

Open ajschwieterman opened 3 years ago

ajschwieterman commented 3 years ago

I'm trying to get the output of an iproxy command using the following code.

const { spawn } = require('child_process');
const cmd = spawn(`iproxy`, [`10101`, `10101`]);
cmd.stdout.on(`data`, (data) => {
    console.log("DATA!!!!");
});

When executing the command in the terminal I can see the following response in the terminal.

Creating listening port 10101 for device port 10101
waiting for connection

However, when using the above code, the data event isn't triggered in the child process. Maybe I'm not using the correct event handler; I'm not sure what's happening.

ajschwieterman commented 3 years ago

Maybe related to #79?

bartekpacia commented 1 year ago

Today I encountered the same problem. Here's the minimum example of it:

$ iproxy 8081:8081
Creating listening port 8081 for device port 8081
waiting for connection

# CTRL+C, this is okay
$ iproxy 8081:8081 1> test.txt 2>&1
# CTRL+C, let's see what was written
$ cat test.txt
# the file is empty - not expected

I was very annoyed by this, but a friend helped me and together we figured out how to make it work (kudos to this SO question):

$ stdbuf -i0 -o0 -e0 iproxy 8081:8081 1> test.txt 2>&1
# CTRL+C
$ cat test.txt
Creating listening port 8081 for device port 8081
waiting for connection

It'd be great if you added some fflush() here and there in iproxy :)