Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iproxy stdout not triggering data event in child process #103

Open
ajschwieterman opened this issue Nov 24, 2020 · 2 comments
Open

iproxy stdout not triggering data event in child process #103

ajschwieterman opened this issue Nov 24, 2020 · 2 comments

Comments

@ajschwieterman
Copy link

ajschwieterman commented Nov 24, 2020

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
Copy link
Author

Maybe related to #79?

@ajschwieterman ajschwieterman changed the title iProxy terminal output event handler iproxy stdout not triggering data event in process Nov 24, 2020
@ajschwieterman ajschwieterman changed the title iproxy stdout not triggering data event in process iproxy stdout not triggering data event in child process Nov 24, 2020
@bartekpacia
Copy link

bartekpacia commented Aug 10, 2022

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants