sys/stropts.h

stratus@tuta.io stratus@tuta.io
Wed Mar 4 14:26:00 GMT 2020


Dear GLIBC,
I just noticed sys/stropts.h has been removed. I was using a function closely derived from the GLIBC manual example, line 640 here which will need updating:
https://github.com/zqqw/consolelogga/blob/master/src/consolelogga.c

The new manual example seems to indicate the affected part can be deleted, and it seems to be only an error check that is probably not essential.
Is that correct, can I safely delete this part? I think it should be fine I guess.
  if (isastream (slave))
    {
      if (ioctl (slave, I_PUSH, "ptem") < 0
          || ioctl (slave, I_PUSH, "ldterm") < 0)
        goto close_slave;
    }

But also, when I was looking at the new example in the manual, I noticed there was a small oversight - the close_slave: goto tag is now unused.

https://www.gnu.org/software/libc/manual/html_node/Allocation.html#index-getpt
int
open_pty_pair (int *amaster, int *aslave)
{
  int master, slave;
  char *name;

  master = getpt ();
  if (master < 0)
    return 0;

  if (grantpt (master) < 0 || unlockpt (master) < 0)
    goto close_master;
  name = ptsname (master);
  if (name == NULL)
    goto close_master;

  slave = open (name, O_RDWR);
  if (slave == -1)
    goto close_master;

  *amaster = master;
  *aslave = slave;
  return 1;

close_slave:
  close (slave);

close_master:
  close (master);
  return 0;
}


Old version:
int
open_pty_pair (int *amaster, int *aslave)
{
  int master, slave;
  char *name;

  master = getpt ();
  if (master < 0)
    return 0;

  if (grantpt (master) < 0 || unlockpt (master) < 0)
    goto close_master;
  name = ptsname (master);
  if (name == NULL)
    goto close_master;

  slave = open (name, O_RDWR);
  if (slave == -1)
    goto close_master;

  if (isastream (slave))
    {
      if (ioctl (slave, I_PUSH, "ptem") < 0
          || ioctl (slave, I_PUSH, "ldterm") < 0)
        goto close_slave;
    }

  *amaster = master;
  *aslave = slave;
  return 1;

close_slave:
  close (slave);

close_master:
  close (master);
  return 0;
}

Yours sincerely,
zqqw.



More information about the Libc-help mailing list