0

I am writing a tool which spawns multiple child processes. In fact 3 levels of child processes to speed up the entire logic/process.

To display the output in terminal I have chosen Curses::UI. The curses ui objects/widgets are created at each level of parent/child relationship and manipulated in the last level of child processes. This multiple levels of child processes seem to be causing issues with the curses display.

I thought it would be stable if I shared just one curses ui object across all child/parent processes.

To achieve this sharing, I am trying to use Storable/Shareable module but not able to get it to run due to errors like these:

quicode sub { │ │ exit; │ │ } caused an error: 'exit' trapped by operation mask at (eval 99) line 2, at my_curser.pl line 147 │ code sub {──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ exit; } caused an error: 'exit' trapped by operation mask at (eval 99) line 2, at my_curser.pl line 147 │ode sub { │ │ exit;

Is it possible to share curses ui object across mutliple processes ?

1 Answers1

0

curses relies on C and terminal or terminal emulator state which is not reliably shareable between processes even from C, and is not visible to Perl wrappers such as UI::Curses. (A terminal has a single "current position"/cursor position; consider what happens if different subprocesses try to update widgets in different parts of the display at the same time.) As such, there is no way you can share these widgets between subprocesses.

In general, a better design is to dedicate a thread or process to the UI and distribute other aspects of processing to other threads/processes.

geekosaur
  • 59,309
  • 11
  • 123
  • 114