Skip to content

No straightforward way to check if popen handle is closed #11492

@locker

Description

@locker

All popen methods (except close) raise an IllegalParams error if the popen handle is closed:

tarantool> p = require('popen').new({'/bin/true'})
---
...

tarantool> p:close()
---
- true
...

tarantool> p:info()
---
- error: 'popen: attempt to operate on a closed handle'
...

tarantool> box.error.last():unpack()
---
- code: 0
  base_type: IllegalParams
  type: IllegalParams
  message: 'popen: attempt to operate on a closed handle'
  trace:
  - file: builtin/box/console.lua
    line: 429
...

This is inconvenient in case a popen handle is created and exported by another module, for example, tarantool/sideservice, which may close it asynchronously at any moment. Intercepting an IllegalParams error doesn't look right.

I see the following ways to make the popen module more user-friendly in this regard:

  • Make info() work even if the popen handle is closed.
  • Add a separate method that could be used for checking if a popen handle is closed.
  • Raise a special error instead of IllegalParams on an attempt to use a closed popen handle. Usage of a closed popen handle doesn't seem to be an illegal parameters issue anyway (all parameters are valid, the state isn't).

Metadata

Metadata

Assignees

Labels

3.5Target is 3.5 and all newer release/master branchesfeatureA new functionalitypopen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions