summaryrefslogtreecommitdiff
path: root/pp_sys.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Reenable numeric first argument of system() on VMS.Craig A. Berry2018-01-011-1/+1
| | | | | | | This was broken in 64def2aeaeb63f92dadc6dfa334, and fixed for Win32 only in 8fe3452cc6ac7af8c08. But VMS also uses a numeric first argument to system() as a flag indicating spawn without waiting for completion.
* make PerlIO handle FD_CLOEXECZefram2017-12-221-6/+0
| | | | | | 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.
* set FD_CLOEXEC atomically in easy casesZefram2017-12-221-34/+13
| | | | | | | 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.
* preserve numericness of system() args on Win32Zefram2017-12-221-4/+31
| | | | | | | | | | | On Windows there's a nasty variation in the meaning of arguments to Perl's system(), in which a numeric first argument isn't used as part of the command to run, but instead selects between two different operations to perform with the command (whether to wait for the command to complete or not). Therefore the reduction of argument scalars to their operative values in the parent process, which was added in commit 64def2aeaeb63f92dadc6dfa33486c1d7b311963, needs to preserve numericness of arguments on Windows. Fixes [perl #132633].
* semicolon-friendly diagnostic controlZefram2017-12-161-8/+8
| | | | | | 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].
* perform system() arg processing before forkZefram2017-12-161-6/+10
| | | | | | | | | | A lot of things can happen when stringifying an argument list: side effects, warnings, exceptions. In the case of system(), these effects should happen in the context of the parent process. The stringification can also depend on which process it happens in, as in the case of $$, and in that case it should also happen in the parent process. Therefore reduce the argument scalars to strings first thing in pp_system. Fixes [perl #121105].
* make exec keep its argument list more reliablyZefram2017-12-141-2/+0
| | | | | | | | | | 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].
* handle null op_next in stacked filetestsZefram2017-12-061-1/+1
| | | | | | | When a filetest op returns false, it skips past following ops that are stacked filetests. The code to do this was assuming that op_next would always be non-null, which is not always the case, for example in a sort comparator. Allow for it to be null. Fixes [perl #129347].
* revert changes to st_ino signedness handlingZefram2017-12-011-5/+4
| | | | | | | | | | | | | This reverts commits 8843856e9716655549cce789b3338e1d4c72fffb, 3676f9e77d46b61f4785aad171f02bed29df0c07, and 793c2ded15ca832d1df1fabbc3b2e7562a057697. As noted in the large comment above the relevant code, the probed ST_INO_SIGN is not reliable enough for its purpose, because Configure makes guesses. The actual compiler knows whether st_ino is signed, and is perfectly capable of optimising out the negative-handling code in the usual case that st_ino is unsigned, without any need for us to preprocess it away.
* More robust version of 793c2ded.Jarkko Hietaniemi2017-11-291-8/+5
| | | | | | In platforms with st.ino always positive, never even see the negative code. Coverity #169271.
* False false.Jarkko Hietaniemi2017-11-281-1/+1
| | | | (Solaris cc got angry.)
* STDCHAR * might not be char *.Jarkko Hietaniemi2017-11-281-1/+1
| | | | | And therefore one may not be able to subtract the pointers, for example in HP-UX.
* In some systems st.ino is never negative.Jarkko Hietaniemi2017-11-281-0/+4
| | | | (Like HP-UX.)
* pp_sys.c: Avoid reparsing stringKarl Williamson2017-11-241-2/+6
| | | | | | | By using is_utf8_invariant_string_loc() instead of plain is_utf8_invariant_string(), we can start parsing at the first variant (if any is found) instead of the previous behavior of starting again at the beginning of the string.
* correctly error on -k "nonexistent" on WindowsZefram2017-11-171-18/+0
| | | | | | | | | | The file test operators for Unix permission bits were returning a blanket false result on systems where the bit being tested for doesn't exist. That's a sensible way to treat a nonexistent bit when statting a file, but the false result was being returned without checking that the argument actually refers to a file. Remove the pre-stat checks for nonexistent bits, so that we get the correct errors for non-files. We still get a blanket false result for nonexistent bits on files.
* set $! when statting a closed filehandleZefram2017-11-151-9/+13
| | | | | | | 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].
* suppress clang warning in inode number handlingZefram2017-11-111-0/+2
| | | | | The gcc warning was already suppressed, but clang needs a different formulation.
* return inode numbers as strings where necessaryZefram2017-11-111-7/+55
| | | | | | | | | We previously used a lossy conversion of inode numbers to floating point, where they're too big to fit the IV/UV format. That sucks; a rounded inode number is nearly useless. Instead, fall back to returning a string of decimal digits. That preserves the entire value, for code that looks at it in the right way, and collapses to the former fallback in other situations.
* pp_sys.c; Use memchr instead of strchrKarl Williamson2017-11-061-1/+2
| | | | | This allows things to work properly in the face of embedded NULs. See the branch merge message for more information.
* Avoid a segfault when untying an objectNicolas R2017-11-021-1/+1
| | | | | Check if the tied object has a stash set before calling UNTIE method.
* (perl #131895) fail stat on names with \0 embeddedTony Cook2017-11-021-6/+23
| | | | Also lstat() and the file test ops.
* pp_sys.c: simplify cpp conditionalsAaron Crane2017-10-211-67/+35
|
* pp_readline,close,getc: explain NULL stack argDavid Mitchell2017-07-271-0/+4
| | | | | | | add code comments to explain why these functions can sometimes be called with a NULL pointer on the stack. (feature introduced by v5.15.2-112-g30901a8)
* make callers of SvTRUE() more efficientDavid Mitchell2017-07-271-1/+1
| | | | | | Where its obvious that the args can't be null, use SvTRUE_NN() instead. Avoid possible multiple evaluations of the arg by assigning to a local var first if necessary.
* use the new PL_sv_zero in obvious placesDavid Mitchell2017-07-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | In places that do things like mPUSHi(0) or newSViv(0), replace them with PUSHs(&PL_sv_zero) and &PL_sv_zero, etc. This avoids the cost of creating and/or mortalising an SV, and/or setting its value to 0. This commit causes a subtle change to tainting in various places as a side-effect. For example, grep in scalar context retunrs 0 if it has no args. Formerly the zero value could in theory get tainted: @a = (); $x = ( ($^X . ""), grep { 1 } @a); It used to be the case that $x would be tainted; now its not. In practice this doesn't matter - the zero value was only getting tainted as a side-effect of tainting's "if anything in the statement uses a tainted value, taint everything" mechanism, which gives (documented) false positives. This commit merely removes some such false positives, and makes the behaviour similar to functions which return &PL_sv_undef/no/yes, which are also immune to side-effect tainting.
* [perl #131645] Fix assert fail in pp_sselectFather Chrysostomos2017-07-021-6/+15
| | | | | | | | | | | | | | | | | pp_sselect (4-arg select) process its first three bitfield arguments first, making sure each one has a valid PV, and then it moves on to the final, timeout argument. SvGETMAGIC() on the timeout argument will wipe out any values the SV holds, so if the same scalar is used as a bitfield argument *and* as the timeout, it will no longer hold a valid PV. Assertions later in pp_sselect make sure there is a valid PV. This commit solves the assertion failure by making a temporary copy of any gmagical or overloaded argument. When the temporary copy is made, the values written to the temporary copies of the bitfield arguments are then copied back to the original magical arguments.
* recv: reset stack when returning undefDavid Mitchell2017-06-221-2/+2
| | | | | | | | | | | When recv() detects an error, it returns undef: but it was failing to pop its args off the stack first. So in list context it returned both its original args and undef. It was also then not extending the stack to push the undef. After this commit it resets SP to the base of its args list first, like the other ops already do which share the Perl_pp_systread() function body.
* pp_leavewrite: extend stack for return valueDavid Mitchell2017-06-221-0/+2
| | | | | | | | | | | | When pushing &PL_sv_yes/no on the stack, make room for it. Normally this isn't an issue as previous formlines() will have caused the stack to be extended anyway; but for the null format: format FOO = . this isn't the case.
* Disallow opening the same symbol as both a file and directory handleDagfinn Ilmari Mannsåker2017-06-051-5/+3
| | | | This has been deprecated since Perl 5.10
* Eliminate remaining uses of PL_statbufDagfinn Ilmari Mannsåker2017-06-011-1/+1
| | | | | | | | | | 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
* Moving variables to their innermost scope.Andy Lester2017-02-181-6/+3
| | | | | | Some vars have been tagged as const because they do not change in their new scopes. In pp_reverse in pp.c, I32 tmp is only used to hold a char, so is changed to char.
* Fix memory leak in generating an exception messageAaron Crane2017-02-041-1/+1
| | | | This was my fault; oops.
* RT#130623: assertions when tying into non-packagesAaron Crane2017-01-241-6/+19
|
* Reading/writing bytes from :utf8 handles will be fatal in 5.30Abigail2017-01-161-2/+4
|
* Opening a file and dir using the same symbol will be fatal in 5.28.Abigail2017-01-161-2/+2
| | | | | | | | Perl 5.10 deprecated using the same symbol to open both a filehandle and a dirhandle, as this can lead to confusing code. In Pelr 5.28, this will become a fatal error. This patch changes the warning to reflect this.
* pp_sys.c: White space onlyKarl Williamson2017-01-131-5/+5
| | | | Vertically align some components of an 'if' for readability.
* Change white space to avoid C++ deprecation warningKarl Williamson2016-11-181-27/+27
| | | | | | | | | | | | | | | | | | | | | | 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.
* Improve error for missing tie() pacakge/methodDagfinn Ilmari Mannsåker2016-11-141-4/+17
| | | | | This brings the error messages in line with the ones used for normal method calls, despite not using call_method().
* make the sysread()/syswrite/() etc :utf8 handle warnings defaultTony Cook2016-11-141-6/+6
| | | | as they should be for deprecation warnings
* (perl #129130) make chdir allocate the stack it needsTony Cook2016-10-241-0/+1
| | | | | chdir with no argument didn't ensure there was stack space available for its result.
* pp_sys.c: use new SvPVCLEAR and constant string friendly macrosYves Orton2016-10-191-4/+4
|
* Add is_utf8_fixed_width_buf_flags() and use itKarl Williamson2016-09-251-6/+2
| | | | | | | | This encodes a simple pattern that may not be immediately obvious to someone needing it. If you have a fixed-size buffer that is full of purportedly UTF-8 bytes, is it valid or not? It's easy to do, as shown in this commit. The file test operators -T and -B can be simpified by using this function.
* Use new is_utf8_valid_partial_char()Karl Williamson2016-08-311-4/+4
| | | | | | | | This new function can be used in the implementation of the file test operators, -B and -T, to see if the whole fixed length buffer is valid UTF-8. Previously if all bytes were UTF-8 except the bytes at the end that could have been a partial character, it assumed the whole thing was UTF-8. This improves the prediction slightly
* Use new name 'is_utf8_invariant_string' in coreKarl Williamson2016-08-311-1/+1
| | | | | | This changes the places in the core to use the clearer synonym added by the previous commit. It also changes one place that hand-rolled its own code to use this function instead.
* [perl #128740] Check for null in pp_ghostent et al.Father Chrysostomos2016-08-011-3/+1
| | | | | | | Specifically in the S_space_join_names_mortal static function that several pp functions call. On some platforms (such as Gentoo Linux with torsocks), hent->h_aliases (where hent is a struct hostent *) may be null after a gethostent call.
* (perl #128316) preserve errno from failed system callsTony Cook2016-06-161-2/+2
|
* make gimme consistently U8David Mitchell2016-02-031-5/+5
| | | | | | | | | | | | | The value of gimme stored in the context stack is U8. Make all other uses in the main core consistent with this. My primary motivation on this was that the new function cx_pushblock(), which I gave a 'U8 gimme' parameter, was generating warnings where callers were passing I32 gimme vars to it. Rather than play whack-a-mole, it seemed simpler to just uniformly use U8 everywhere. Porting/bench.pl shows a consistent reduction of about 2 instructions on the loop and sub benchmarks, so this change isn't harming performance.
* convert CX_PUSHFORMAT/POPFORMAT to inline fnsDavid Mitchell2016-02-031-2/+2
| | | | | | Replace CX_PUSHFORMAT() with cx_pushformat() etc. No functional changes.
* convert CX_PUSH/POP/TOPBLOCK to inline fnsDavid Mitchell2016-02-031-2/+2
| | | | | | Replace CX_PUSHBLOCK() with cx_pushblock() etc. No functional changes.
* rename PUSHBLOCK,PUSHSUB etc to CX_PUSHBLOCK etcDavid Mitchell2016-02-031-2/+2
| | | | | | | Earlier all the POPFOO macros were renamed to CX_POPFOO to reflect the changed API (like POPBLOCK no longer decremented cxstack_ix). Now rename the PUSH ones for consistency.