code: def test_webcam_process_termination():
      """
      Test for issue #343. Ensures that an ffmpeg process streaming from
      webcam is terminated properly when the reader is closed.
  
      """
  
      pids0 = get_ffmpeg_pids()
  
      try:
          # Open the first webcam found.
          with iio.get_reader("<video0>") as reader:
              assert reader._read_gen is not None
              assert get_ffmpeg_pids().difference(pids0)
          # Ensure that the corresponding ffmpeg process has been terminated.
          assert reader._read_gen is None
          assert not get_ffmpeg_pids().difference(pids0)
      except IndexError:
          pytest.xfail("no webcam")
  
imports: import gc
  import os
  import platform
  import sys
  import threading
  import time
  import warnings
  from io import BytesIO
  from pathlib import Path
  import imageio.plugins
  import imageio.v2
  import imageio.v3
  import numpy
  import pytest
  from imageio import core
  from imageio.core import IS_PYPY
  from conftest import deprecated_test
label_desc: Use image node_id 22 for calling a global function with example usage: test_webcam_process_termination() without return types