luatest icon indicating copy to clipboard operation
luatest copied to clipboard

Rewrite Process in Popen

Open olegrok opened this issue 4 years ago • 2 comments

Also such approach should preserve backward compatibility (old versions should use old code). But new Tarantool versions 2.4 should works fine. Maybe it will fix https://github.com/tarantool/luatest/issues/120 .

olegrok avatar Mar 29 '21 17:03 olegrok

During solution #252 , we tried to rewrite the module, but decided to postpone it indefinitely. These are notes about what we managed to find out (for the future):

  • list of possible problems with popen;
  • ffi pipe and popen popen are not compatible (by interfaces);
  • output_beatifier:hijack_output(...) not needed because POPEN will do it; https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L64-L66
  • processing of arguments and environment variables is not necessary: https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L67-L68
  • there are some limitations in popen:new(), you need to use popen:shell();
  • you can replace the read function (a more correct option): https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/ffi_io.lua#L32-L47
  • see #312 about this logic (diagram) https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L51-L59
  • ffi.gc works correctly with popen https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L78-L81

ochaplashkin avatar Jun 29 '23 13:06 ochaplashkin

ffi pipe and popen popen are not compatible (by interfaces);

This issue was written when 1.10 was relevant. Currently it's not so. You don't need to care about ffi and popen compatibility.

olegrok avatar Jul 02 '23 17:07 olegrok