Do you know where your variables are? | |
PerlMonks |
Re^2: Mechanism for ensuring only one instance of a Perl script can only run?by afoken (Chancellor) |
on Dec 02, 2022 at 22:56 UTC ( [id://11148510]=note: print w/replies, xml ) | Need Help?? |
I don't think that will always work safely:
Trying to locking the executable should be free of race conditions (or else flock() would be severely broken) and should also work with soft and hard links, as the file is locked, not one of its directory entries. Quick assign to $0 demo:
pstree on a host with about 10 containers (running Proxmox VE, both host and containers using Debian 11) systemd─┬─agetty ├─cron ├─dbus-daemon ├─dovecot─┬─anvil │ ├─config │ └─log ├─8*[dtach───lxc-console] ├─2*[iscsid] ├─lxc-monitord ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─dhclient───3*[{dhclient}] │ ├─es-ct18-linux-a │ ├─nullmailer-send │ ├─perl │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─apache2───10*[apache2] │ ├─cron │ ├─dbus-daemon │ ├─dhclient───3*[{dhclient}] │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─dhclient───3*[{dhclient}] │ ├─mini_httpd │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─dhclient───3*[{dhclient}] │ ├─dovecot─┬─anvil │ │ ├─auth │ │ ├─config │ │ ├─imap │ │ ├─log │ │ └─stats │ ├─exim4 │ ├─multi-fetchmail───8*[fetchmail] │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─mini_httpd │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ ├─systemd-resolve │ └─urbackupsrv───20*[{urbackupsrv}] ├─lxc-start───systemd─┬─3*[agetty] │ ├─apache2───5*[apache2] │ ├─cron │ ├─dbus-daemon │ ├─dhclient───3*[{dhclient}] │ ├─nullmailer-send │ ├─postgres───6*[postgres] │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─dhclient───3*[{dhclient}] │ ├─lighttpd │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─mini_httpd │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─apache2───2*[apache2───26*[{apache2}]] │ ├─cron │ ├─dbus-daemon │ ├─mini_httpd │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ └─systemd-resolve ├─lxc-start───systemd─┬─3*[agetty] │ ├─cron │ ├─dbus-daemon │ ├─lighttpd │ ├─nmbd │ ├─nullmailer-send │ ├─rsyslogd───2*[{rsyslogd}] │ ├─smbd─┬─cleanupd │ │ ├─lpqd │ │ ├─smbd │ │ └─smbd-notifyd │ ├─systemd-journal │ ├─systemd-logind │ ├─systemd-network │ ├─systemd-resolve │ └─vsftpd ├─lxcfs───6*[{lxcfs}] ├─mdadm ├─mini_httpd ├─nullmailer-send ├─pmxcfs───12*[{pmxcfs}] ├─pve-firewall ├─pve-ha-crm ├─pve-ha-lrm ├─pve-lxc-syscall───2*[{pve-lxc-syscall}] ├─pvedaemon───3*[pvedaemon worke] ├─pvefw-logger───{pvefw-logger} ├─pveproxy───3*[pveproxy worker] ├─pvescheduler ├─pvestatd ├─qmeventd ├─rpcbind ├─rrdcached───12*[{rrdcached}] ├─rsyslogd───3*[{rsyslogd}] ├─smartd ├─spiceproxy───spiceproxy work ├─sshd───sshd───sshd───bash───sudo───bash───pstree ├─systemd───(sd-pam) ├─systemd-journal ├─systemd-logind ├─systemd-timesyn───{systemd-timesyn} ├─systemd-udevd ├─watchdog-mux └─zed───2*[{zed}] Every lxc-start is a parent process of a container, every systemd that is a child of a lxc-start is the init process (pid 1) of a container, each of those systemds and all of their children are running in a container. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom
|
|