Как получить сетевое пространство имен Linux для устройства tap/tun, указанное в /proc/[PID]/fdinfo/[FD]?

De acuerdo con los manuales de bashy zsh, sí, de hecho puede trapcualquier señal.

bash:

   trap [-lp] [[arg] sigspec...]
          The command arg is to be read and executed when the shell receives signal(s) sigspec.  If arg is absent (and there is a single sigspec) or  -,  each  specified  signal  is
          reset  to  its  original disposition (the value it had upon entrance to the shell).  If arg is the null string the signal specified by each sigspec is ignored by the shell
          and by the commands it invokes.  If arg is not present and -p has been supplied, then the trap commands associated with each sigspec are displayed.  If  no  arguments  are
          supplied  or  if  only -p is given, trap prints the list of commands associated with each signal.  The -l option causes the shell to print a list of signal names and their
          corresponding numbers.  Each sigspec is either a signal name defined in <signal.h>, or a signal number.  Signal names are case insensitive and the SIG prefix is  optional.

zsh:

   trap [ arg ] [ sig... ]
          arg is a series of commands (usually quoted to protect it from immediate evaluation by the shell) to be read and executed when the shell receives any of the signals speci-
          fied by one or more sig args.  Each sig can be given as a number, or as the name of a signal either with or without the string SIG in front (e.g. 1, HUP,  and  SIGHUP  are
          all the same signal).
3
07.03.2019, 21:48
1 ответ

Вы можете попробовать сопоставить интерфейс tun по его аппаратному адресу, а не по имени (вы можете получить это с помощью ioctl(SIOCGIFHWADDR)в дескрипторе файла tun/tap ).

Я не думаю, что есть что-то проще, иначе не понадобилось бы недавнее изменение вроде this (, которое добавляет возможность получения сетевого пространства имен интерфейса через tun fd ). и принято.

1
27.01.2020, 21:29

Теги

Похожие вопросы