code: def _check_ioctl_mutate_len(self, nbytes=None):
      buf = array.array("i")
      intsize = buf.itemsize
      ids = (os.getpgrp(), os.getsid(0))
      # A fill value unlikely to be in `ids`
      fill = -12345
      if nbytes is not None:
          # Extend the buffer so that it is exactly `nbytes` bytes long
          buf.extend([fill] * (nbytes // intsize))
          self.assertEqual(len(buf) * intsize, nbytes)  # sanity check
      else:
          buf.append(fill)
      with open("/dev/tty", "rb") as tty:
          r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, True)
      rpgrp = buf[0]
      self.assertEqual(r, 0)
      self.assertIn(rpgrp, ids)
  
file_path: cpython/Lib/test/test_ioctl.py
imports: import array
  import unittest
  from test.support import get_attribute
  from test.support.import_helper import import_module
  import os, struct
label_desc: Use image node_id 2 for calling the IoctlTests obj's underlying member method code with example usage: obj._check_ioctl_mutate_len(nbytes) without return types