From 11c6e5fc65f26ba5219997d19707b998a9abf26d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 7 Mar 2020 22:52:33 +0000 Subject: tl20 perl 5.30.1 for Windows, from Siep git-svn-id: svn://tug.org/texlive/trunk@54166 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tlperl/lib/Test2/Util.pm | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'Master/tlpkg/tlperl/lib/Test2/Util.pm') diff --git a/Master/tlpkg/tlperl/lib/Test2/Util.pm b/Master/tlpkg/tlperl/lib/Test2/Util.pm index 6de008b683d..c4a865e9b15 100755 --- a/Master/tlpkg/tlperl/lib/Test2/Util.pm +++ b/Master/tlpkg/tlperl/lib/Test2/Util.pm @@ -2,7 +2,7 @@ package Test2::Util; use strict; use warnings; -our $VERSION = '1.302133'; +our $VERSION = '1.302162'; use POSIX(); use Config qw/%Config/; @@ -29,6 +29,8 @@ our @EXPORT_OK = qw{ ipc_separator + gen_uid + do_rename do_unlink try_sig_mask @@ -157,6 +159,9 @@ sub pkg_to_file { sub ipc_separator() { "~" } +my $UID = 1; +sub gen_uid() { join ipc_separator() => ($$, get_tid(), time, $UID++) } + sub _check_for_sig_sys { my $sig_list = shift; return $sig_list =~ m/\bSYS\b/; @@ -178,7 +183,7 @@ my %PERLIO_SKIP = ( sub clone_io { my ($fh) = @_; - my $fileno = fileno($fh); + my $fileno = eval { fileno($fh) }; return $fh if !defined($fileno) || !length($fileno) || $fileno < 0; @@ -329,6 +334,30 @@ otherwise it returns 0. Convert a package name to a filename. +=item $string = ipc_separator() + +Get the IPC separator. Currently this is always the string C<'~'>. + +=item $string = gen_uid() + +Generate a unique id (NOT A UUID). This will typically be the process id, the +thread id, the time, and an incrementing integer all joined with the +C. + +These ID's are unique enough for most purposes. For identical ids to be +generated you must have 2 processes with the same PID generate IDs at the same +time with the same current state of the incrementing integer. This is a +perfectly reasonable thing to expect to happen across multiple machines, but is +quite unlikely to happen on one machine. + +This can fail to be unique if a process generates an id, calls exec, and does +it again after the exec and it all happens in less than a second. It can also +happen if the systems process id's cycle in less than a second allowing 2 +different programs that use this generator to run with the same PID in less +than a second. Both these cases are sufficiently unlikely. If you need +universally unique ids, or ids that are unique in these conditions, look at +L. + =item ($ok, $err) = do_rename($old_name, $new_name) Rename a file, this wraps C in a way that makes it more reliable @@ -409,7 +438,7 @@ F. =head1 COPYRIGHT -Copyright 2018 Chad Granum Eexodist@cpan.orgE. +Copyright 2019 Chad Granum Eexodist@cpan.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -- cgit v1.2.3