| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix the various Perl_PerlSock_dup2_cloexec() type functions so that
t/porting/liberl.a passes under -DPERL_GLOBAL_STRUCT_PRIVATE builds.
In these builds it is forbidden to have any static variables, but each
of these functions (via convoluted macros) has a static var called
'strategy' which records, for each function, whether a run-time probe
has been done to determine the best way of achieving close-exec
functionality, and the result.
Replace them all with 'global' vars: PL_strategy_dup2 etc.
NB these vars aren't thread-safe but it doesn't really matter, as the
worst that can happen is for a redundant probe or two to be done before
a suitable "don't probe any more" value is written to the var and seen
by all the threads.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
during global destruction.
This means that code like:
perl -i -ne '...; last'
will replace the input file with the in-place edit output of the file,
but:
perl -i -ne '...; die'
or
perl -i -ne '...; exit 1'
won't.
|
| |
|
| |
|
|
|
|
|
| |
This moves calculations definitely to compile time; some optimizing
compilers may already do this, but some may not.
|
|
|
|
|
|
|
|
| |
Previously the directory handle was only closed if the rest of the
magic free clean up is done, but in most success cases that code
doesn't run, leaking the directory handle.
So always close the directory if our AV is available.
|
|
|
|
|
|
| |
This reverts commit 523d71b314dc75bd212794cc8392eab8267ea744, reinstating
commit 2cdf406af42834c46ef407517daab0734f7066fc. Reversion is not the
way to address the porting problem that motivated that reversion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 2cdf406af42834c46ef407517daab0734f7066fc.
The reason for the revert is that with this commit, perl fails to
compile on darwin (or at least, one some versions of it):
./miniperl -Ilib make_ext.pl lib/auto/DB_File/DB_File.bundle MAKE="/Applications/Xcode.app/Contents/Developer/usr/bin/make" LIBPERL_A=libperl.a LINKTYPE=dynamic
Parsing config.in...
Looks Good.
dyld: lazy symbol binding failed: Symbol not found: _mkostemp
Referenced from: /private/tmp/perl/cpan/DB_File/../../miniperl
Expected in: flat namespace
dyld: Symbol not found: _mkostemp
Referenced from: /private/tmp/perl/cpan/DB_File/../../miniperl
Expected in: flat namespace
Unsuccessful Makefile.PL(cpan/DB_File): code=5 at make_ext.pl line 518.
make: *** [lib/auto/DB_File/DB_File.bundle] Error 2
|
|
|
|
|
|
| |
Move handling of close-on-exec flag for PerlIO handles into PerlIO itself.
Where PerlIO opens new file descriptors, have them opened in O_CLOEXEC
mode where possible.
|
|
|
|
|
|
| |
Like the other "_cloexec" I/O functions, this guarantees to return a
file descriptor with FD_CLOEXEC set, and will set the flag atomically
if possible.
|
| |
|
|
|
|
|
|
|
| |
In many places where a file descriptor is being opened, open it with
FD_CLOEXEC already set if possible. This commit covers the easy cases,
where the file descriptor arises without the use of PerlIO, pp_open,
or my_popen.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New functions PerlLIO_dup_cloexec(), PerlLIO_dup2_cloexec(),
PerlLIO_open_cloexec(), PerlLIO_open3_cloexec(), PerlProc_pipe_cloexec(),
PerlSock_socket_cloexec(), PerlSock_accept_cloexec(), and
PerlSock_socketpair_cloexec() each do the same thing as their
"_cloexec"-less counterpart, but return with the FD_CLOEXEC flag set on
each new file descriptor. They set the flag atomically as part of the
file descriptor creation syscall where possible, but will fall back to
setting it separately from creation where necessary.
In all cases, setting the flag atomically depends not only on the correct
syscall interface being defined, but on it being actually implemented
in the runtime kernel. Each function will experiment to see whether
the atomic flag setting actually works, and is prepared for the flag to
cause EINVAL or ENOSYS or to be ignored.
|
|
|
|
|
|
| |
New macros {GCC,CLANG}_DIAG_{IGNORE,RESTORE}_{DECL,STMT}, which take a
following semicolon. It is necessary to use the _DECL or _STMT version
as appropriate to the context. Fixes [perl #130726].
|
|
|
|
|
|
|
|
|
|
| |
Bits of exec code were putting the constructed commands into globals
PL_Argv and PL_Cmd, which could then be clobbered by reentrancy.
These are only global in order to manage their freeing, but that's
better managed by using the scope stack. So replace them with automatic
variables, with ENTER/SAVEFREEPV/LEAVE to free the memory. Also copy
the strings acquired from SVs, to avoid magic clobbering the buffers of
SVs already read. Fixes [perl #129888].
|
|
|
|
| |
and adjust the error message for renaming the work file
|
|
|
|
| |
But t/run/switches.t test 131 still fails, with perl.exe crashing.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
NetBSD 6 provides renameat() etc in it's libc, but in the cases where
we use them they fail with ENOSYS.
So I've modified the in-place edit clean up code to attempt to
fallback to the non-at versions of these functions, after checking
that the current directory is sane.
Once I was sure that worked, since the *at() functions don't work for
my use case on NetBSD 6, I've disabled them in hints.
|
|
|
|
| |
Coverity #169257, #169265, #169269.
|
|
|
|
| |
Coverity #169258.
|
|
|
|
|
|
|
| |
When a stat fails because it's on a closed or otherwise invalid
filehandle, $! was often not being set, depending on the operation
and the nature of the invalidity. Consistently set it to EBADF.
Fixes [perl #108288].
|
|
|
|
|
| |
This allows things to work properly in the face of embedded NULs.
See the branch merge message for more information.
|
|
|
|
|
|
|
|
|
|
| |
The original names are confusing.
See thread beginning with
http://nntp.perl.org/group/perl.perl5.porters/244335
The two macros are mapped into just that one, complementing the result
for the few cases where strNEs was used.
|
|
|
|
| |
Also lstat() and the file test ops.
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit d4bd48023fe0ba950fface5aa859b6852aa29fc4.
perlio.h depends on vmsish.h and comes in (via iperlsys.h) about
a thousand lines later in perl.h. So we can't put a prototype
that uses PerlIO in vmsish.h
Maybe there is a way to get that prototype out of doio.c, but
this isn't it.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This should call execvp() with an empty argv array (containing only the
terminating NULL pointer), but was instead just returning false (and not
setting $!).
Executing a program with an empty argv array is valid ISO C: it merely
requires argc to be nonnegative and argv[argc] to be NULL. POSIX states
that that argv[0] "should point to a filename string that is associated
with the process being started", but "should" only applies to
applications claiming strict POSIX conformance. Perl does not, and
certainly should not impose it on perl programs.
This also requires handling the case where both PROGRAM and LIST are
empty, to avoid calling execvp(NULL, …), which _is_ invalid. I've made
it return ENOENT, which it the error POSIX specifies for execvp("", …).
|
|
|
|
|
|
| |
As suggested by Zefram.
For: RT #132087.
|
|
|
|
|
| |
renameat() on FreeBSD 11 fails if the paths supplied are absolute
paths.
|
| |
|
|
|
|
|
| |
based in the inode/device numbers when we don't have the *at()
functions.
|
|
|
|
| |
and ensure we (attempt to) clean up the work file
|
|
|
|
| |
and that we clean up the temp file
|
|
|
|
|
|
|
|
|
|
| |
This avoids trying to rename the work file over the original
multiple times, which could make the implicit (or explicit) close
fail.
This is an incompatibility with the pre-workfile version of in-place
editing, since you could previously fork a child to do process a
given file, but hopefully this is a rare case.
|
|
|
|
| |
This also avoids double closedir()ing the directory handle.
|
|
|
|
|
|
| |
Unfortunately this means systems that don't have the *at() functions
aren't protected from code that chdir()s in the middle of in-place
editing a file.
|
|
|
|
|
| |
It can be closed by either iterating to the next file, or by
an explicit close(ARGVOUT);
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously in-place editing opened the file then immediately
*replaced* the file, so if an error occurs while writing the output,
such as running out of space, the content of the original file is lost.
This changes in-place editing to write to a work file which is renamed
over the original only once the output file is successfully closed.
It also fixes an issue with setting setuid/setgid file modes for
recursive in-place editing.
|
|
|
|
|
|
|
|
|
|
| |
Give Perl_nextargv its own statbuf and pass a pointer to it into
Perl_do_open_raw and thence S_openn_cleanup when needed.
Also reduce the scope of the existing statbuf in Perl_nextargv to make
it clear it's distinct from the one populated by do_open_raw.
Fix perldelta entry for PL_statbuf removal
|
|
|
|
|
| |
Strangely, this was apparently found already in 2014, but it now
(rightfully) showed up. Coverity database tweak?
|
|
|
|
| |
Except under cpan/ and dist/
|
|
|
|
| |
cando() has not used PL_statcache since Perl 3 (commit a687059cbaf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
C++11 requires space between the end of a string literal and a macro, so
that a feature can unambiguously be added to the language. Starting in
g++ 6.2, the compiler emits a warning when there isn't a space
(presumably so that future versions can support C++11). Unfortunately
there are many such instances in the perl core. This commit fixes
those, including those in ext/, but individual commits will be used for
the other modules, those in dist/ and cpan/.
This commit also inserts space at the end of a macro before a string
literal, even though that is not deprecated, and removes useless ""
literals following a macro (instead of inserting a blank). The result
is easier to read, making the macro stand out, and be clearer as to the
intention.
Code and modules included with the Perl core need to be compilable using
C++. This is so that perl can be embedded in C++ programs. (Actually,
only the hdr files need to be so compilable, but it would be hard to
test that just the hdrs are compilable.) So we need to accommodate
changes to the C++ language.
|
| |
|
|
|
|
|
|
|
|
|
| |
This reverts commit f95ba548a286b17c260cc168715a9d0d441b14a6.
[rt.perl.org #128967]
The negative arguments to fchown depend on the platform,
so Coverity should not claim it knows what is acceptable.
|
|
|
|
|
|
|
|
|
|
|
|
| |
When miniperl calls csh to implement glob(), we clear %ENV temporarily
to avoid csh dying on invalid values for things like LS_COLORS. That
has proven to have far too many problems, since many system-dependent
env vars are necessary for calling an external process. See the RT
ticket for details.
A better solution is temporarily to clear only those vars that are
known to be problematic and make csh possibly fail. There only hap-
pens to be one of those at present, namely LS_COLORS.
|
| |
|
|
|
|
| |
Coverity CID 135145: Argument cannot be negative (NEGATIVE_RETURNS)
|