GNU Screen -lsは常にゼロ以外の値を返しますか?

GNU Screen -lsは常にゼロ以外の値を返しますか?

画面に関連するスクリプトを実行していますが、次のようになります。screen -ls いつも返品1.正常ですか?

画面のマニュアルページには合格すると興味深い作業が行われていることが示されていますが、screen -ls -q私はそうしませんでした(これがうまくいか-qないことも注目に値します)。


わかった今本物混乱してください。 Gnu画面ソースを見ています。

if (lsflag) {
    int i, fo, oth;

    if (multi)
        real_uid = multi_uid;
    SET_GUID();
    i = FindSocket((int *)NULL, &fo, &oth, SocketMatch);
    if (quietflag) {
        if (rflag)
            exit(10 + i);
        else
            exit(9 + (fo || oth ? 1 : 0) + fo);
    }
    if (fo == 0)
        Panic(0, "No Sockets found in %s.\n", SocketPath);
    Msg(0, "%d Socket%s in %s.", fo, fo > 1 ? "s" : "", SocketPath);
    eexit(0);
}

lsflag-lまたは、コマンドを実行すると、-ls設定はeexit次のようになります。

void eexit(int e)
{
    if (ServerSocket != -1) {
        if (setgid(real_gid))
            AddStr("Failed to set gid\r\n");
        if (setuid(real_uid))
            AddStr("Failed to set uid\r\n");
        if (unlink(SocketPath))
            AddStr("Failed to remove socket\r\n");
    }
    exit(e);
}

1も返すべきではありませんscreen -ls

ベストアンサー1

ソースをもっと詳しく見ると答えが出ました。いつものように、これは Debian がコアコンポーネントの以前のバージョンをリリースするからです。

 if (lsflag)
    {
      int i, fo, oth;

#ifdef MULTIUSER
      if (multi)
        real_uid = multi_uid;
#endif
      SET_GUID();
      i = FindSocket((int *)NULL, &fo, &oth, SockMatch);
      if (quietflag) {
        if (rflag)
          exit(10 + i);
        else
          exit(9 + (fo || oth ? 1 : 0) + fo);
      }
      if (fo == 0)
        Panic(0, "No Sockets found in %s.\n", SockPath);
      Panic(0, "%d Socket%s in %s.\n", fo, fo > 1 ? "s" : "", SockPath);
      /* NOTREACHED */
    }

そのうちパニックは次のとおりです。

void Panic (int err, const char *fmt, VA_DOTS)
{
  char buf[MAXPATHLEN*2];
  PROCESS_MESSAGE(buf);

  debug3("Panic('%s'); display=%x displays=%x\n", buf, display, displays);
  if (displays == 0 && display == 0)
    {
      printf("%s\r\n", buf);
      if (PanicPid)
        Kill(PanicPid, SIG_BYE);
    }
  else if (displays == 0)
    {
      /* no displays but a display - must have forked.
       * send message to backend!
       */
      char *tty = D_usertty;
      display = 0;
      SendErrorMsg(tty, buf);
      sleep(2);
      _exit(1);
    }
  else
    for (display = displays; display; display = display->d_next)
      {
        if (D_status)
      RemoveStatus();
        FinitTerm();
        Flush(3);
#ifdef UTMPOK
        RestoreLoginSlot();
#endif
        SetTTY(D_userfd, &D_OldMode);
        fcntl(D_userfd, F_SETFL, 0);
        write(D_userfd, buf, strlen(buf));
        write(D_userfd, "\n", 1);
        freetty();
    if (D_userpid)
      Kill(D_userpid, SIG_BYE);
      }
#ifdef MULTIUSER
  if (tty_oldmode >= 0)
    {
# ifdef USE_SETEUID
      if (setuid(own_uid))
        xseteuid(own_uid);  /* may be a loop. sigh. */
# else
      setuid(own_uid);
# endif
      debug1("Panic: changing back modes from %s\n", attach_tty);
      chmod(attach_tty, tty_oldmode);
    }
#endif
  eexit(1);
}

Panic()メンバーを通じて渡されたエラーコードを返さない理由については、errあなたの推測も私と同じです。-Q存在するのですが、この主張も崩れたようです。

デフォルトではバージョンがapt壊れています。

おすすめ記事