Comments (11)
This is currently not supported. I am not sure if closing the pipe's output end of the parent process (erlexec
) will in fact signal the end of file in the spawned child (tac
). The first example is different from the second, because in the second case the tac
is invoked by the command shell via popen()
versus execv()
invocation in the first case.
You can try to introduce a new command in exec.cpp
that will lookup the pid of the child process state, close the writing end of the pipe, and see if it triggers the OS to close the corresponding stdin
end of the pipe in the child process. If so, you are welcome to send a PR.
from erlexec.
The first example is different from the second, because in the second case the
tac
is invoked by the command shell viapopen()
versusexecv()
invocation in the first case.
It is actually exact way how the shell is doing it. It opens pipe by popen()
and then it calls execve()
in child. How do you think shell executes tac
? :-)
from erlexec.
I would think the shell does it differently - via the pipe/fork/exec combination since popen()
only returns a stream, and as the result the child is already spawned so there's no need to call execve()
explicitly. I haven't looked at the library sources for the popen()
, but I am nearly certain that it's got the execve()
call in its implementation.
from erlexec.
From the manual:
The
popen()
function opens a process by creating a pipe, forking, and invoking the shell.
popen()
is just a function which does all those steps for you but the mechanism behind is exactly same.
from erlexec.
For example: http://cnds.eecs.jacobs-university.de/courses/os-2010/src/popen/popen.c
from erlexec.
From BSD: http://www.retro11.de/ouxr/211bsd/usr/src/lib/libc/gen/popen.c.html
Exactly same shit :)
from erlexec.
Unfortunately, I'm not familiar with C++ only C.
from erlexec.
Nice:
1> application:start(erlexec).
ok
2> Watcher = spawn(fun F() -> receive Msg -> io:format("Got: ~p~n", [Msg]), F() end end).
<0.112.0>
3> {ok, Pid, OsPid} = exec:run("tac", [stdin, {stdout, Watcher}, {stderr, Watcher}]).
{ok,<0.114.0>,26143}
4> exec:send(Pid, <<"foo\n">>).
ok
5> exec:send(Pid, <<"bar\n">>).
ok
6> exec:send(Pid, <<"baz\n">>).
ok
7> exec:send(Pid, eof).
ok
Got: {stdout,26143,<<"baz\nbar\nfoo\n">>}
from erlexec.
I can't get it why they can't implement it in Erlang OTP as well.
from erlexec.
13 tests, 0 failures
:)
from erlexec.
Yes, that exec:send(Pid, eof).
makes sense, since it signifies the consumer's end of an end of input.
from erlexec.
Related Issues (20)
- Disable erl_interface for Erlang 23 HOT 1
- :env option in 1.18.8 HOT 2
- Establishing/Supervising Communications With a Long-Running, Data Streaming Python Process HOT 3
- New release? Resolve port hanging HOT 2
- Exit codes appear to be x256 too large HOT 1
- erlexec on linux slows down when nofile limit is a large value HOT 2
- Mac OS error: use of undeclared identifier 'pipe2' HOT 2
- Could not compile dependency :erlexec HOT 15
- I am running into issues with elixir release HOT 3
- When native stdin process buffer is full, erlexec does not retry HOT 11
- PTY dynamic option test failing HOT 6
- Does 2.0.0 contain a breaking change? HOT 1
- Compile failure on OSX M1 mac HOT 4
- Passing command arguments as list HOT 1
- USE_POLL is not set HOT 1
- Failed build on FreeBSD HOT 9
- Compile fails on arm HOT 4
- Any command terminates with exit status 132 HOT 8
- Issue on ARM Mac HOT 9
- Erlexec compile fails on FreeBSD 14 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from erlexec.