Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-3098

foreground processes should detect whether they have a user-controlled terminal

XMLWordPrintable

      Feature request ZBXNEXT-611 adds support for running processes in foreground. This opens some interesting opportunities for user interaction.

      For instance (quoting from (14) from ZBXNEXT-611), some programs like "ls" provide "--color" option:

            --color[=WHEN]         colorize the output; WHEN can be 'never', 'auto',
                                     or 'always' (the default); more info below
      
      Using color to distinguish file types is disabled both by default and
      with --color=never.  With --color=auto, ls emits color codes only when
      standard output is connected to a terminal.  The LS_COLORS environment
      variable can change the settings.  Use the dircolors command to set it.
      

      We can do similarly and only output the following message if we are connected to a user-controlled terminal:

      if (0 != (flags & ZBX_TASK_FLAG_FOREGROUND))
      {
      	printf("Starting Zabbix Server. Zabbix %s (revision %s).\nPress Ctrl+C to exit.\n\n",
      			ZABBIX_VERSION, ZABBIX_REVISION);
      }
      

      Also, as wiper suggested, we can colorize console output, like so:

      Idea by sasha is that we can colorize based on message severity level instead.

            Unassigned Unassigned
            asaveljevs Aleksandrs Saveljevs
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: