Work with stdin and stdout subsidiary process simultaneously in lua
When the lua scrupt was written, it came to one thing: io.popen, judging by http://www.lua.ru/doc/5.7.html may not transfer at the same time the descriptors stdin and stdout of the launch process.
Example of problem code:
cmdexecute = function(cmd, input) local f = io.popen(cmd, "w"); if tostring(input) ~= nil then f:write(tostring(input)); end; local l = f:read("*a"); f:close(); return (l); end;
if cmdexecute('xargs ps', 'aux') ~= nil then
print 'ps aux что-то выдал';
print 'ps aux промолчал';
Длинный-длинный вывод ps aux...
ps aux промолчал
It should be the idea:
ps aux что-то выдал
Question: How do you get the descriptors and stdin and stdout from popen? Or maybe there's some other solution to the task, free
Upd: Because of the relevance of the question, I explain: decisions c
io.popen gives an interface to the system posix function popen, yes, it can only work one way. In your case, you don't need to write anything in ps. If you open it for reading, she'll read it. But I understand.
psYou only have an example...
POSIX has only one way to deal with both file descriptors of the process. Setting up a pair of sockets, linking one of these compounds to file descriptors 0 and 1
forkand the daughter-in-law cause a proper program.
In Lua, there is no evidence of such funds. So the direct answer to your question is to get stdin and stdout at the same time impossible. Only the redirection of the programme to the file and the subsequent reading of the file can be seen from the decisions. Or an entry for the program is written in advance and submitted to the entrance. And we can still experiment with known channels.
mkfifoTo create a nameable channel in the file system to send it to the program or the recording from the program to redirect it into it and to lua to open this channel as a regular file and try writing/reading.
How do I define in Awk a delimiter consisting of more than one character?
Software Programming • • inna
Why doesn't it work if is_tax in the subsidiary categories of Taxonia WP?
Software Programming • • emmalee
Pros/cons of discontinuing a DevOps workflow?
Continuous Integration and Delivery (CI, CD) • • emran
The process cannot access the file because it is being used by another process
Software Programming • • Alberto
Differences between one: Linux and Windows Development Environment
Software Programming • • Nykeriab
The event of the "onmouseover" ceases to work in the introduction of the subsidiary element into the text. How do you fix it?
Software Programming • • Duquan