summaryrefslogtreecommitdiff
path: root/doio.c
Commit message (Collapse)AuthorAgeFilesLines
* perlapi: Document do_closeKarl Williamson2022-06-011-1/+17
|
* doio.c: Rename formal parameters for clarityKarl Williamson2022-05-271-15/+15
| | | | | | | | | | This was named 'not_implicit' instead of 'explicit' because the latter is a C++ keyword. But a negative name increases the cognitive load of understanding, and in this case resulted in some double negatives, which is worse. 'is_explicit' isn't a keyword and is a clearer name for this concept.
* doio.c: Properly indent some nested #if linesKarl Williamson2022-05-181-4/+4
|
* perlapi: Document my_chsizeKarl Williamson2022-05-111-0/+8
|
* Revert "Mark internal and document do_close"Karl Williamson2022-05-071-9/+1
| | | | | | This reverts commit 2ad26d7ef45dfa5bf5ac485939c7d3e6f47485d8. A pull request will be submitted to garner feedback.
* Mark internal and document do_closeKarl Williamson2022-05-071-1/+9
|
* Revert "Fix GH Issue #19472: read warnings from open($fh,">",\(my $x))"Yves Orton2022-03-141-10/+0
| | | | | | | This reverts commit 8b03aeb95ab72abdb2fa40f2d1196ce42f34708d. This is causing BBC breakage, and its unimport and grey zone enough that we can pick it up in 5.37 when we have more time to deal with it.
* Fix GH Issue #19472: read warnings from open($fh,">",\(my $x))Yves Orton2022-03-071-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | We produce all kinds of warnings if someone opens a scalar reference that is undef. Prior to this we handled write operations ok, at least in blead, but read operations would produce a plethora of warnings. To me this analogous to treating an undef var as hash and trying to read from it, we autovivify the undef var to be a hash. So in this case we should just "autovivify" the referenced scalar to be an empty string. Eg. before this patch: ./perl -Ilib -wle'open my $fh,"+>", \(my $v); my @x=<$fh>; print 0+@x' Use of uninitialized value $fh in <HANDLE> at -e line 1. Use of uninitialized value $fh in <HANDLE> at -e line 1. Use of uninitialized value $fh in <HANDLE> at -e line 1. Use of uninitialized value $fh in <HANDLE> at -e line 1. Use of uninitialized value $fh in <HANDLE> at -e line 1. Use of uninitialized value $fh in <HANDLE> at -e line 1. Use of uninitialized value $fh in <HANDLE> at -e line 1. 0 After it: ./perl -Ilib -wle'open my $fh,"+>", \(my $v); my @x=<$fh>; print 0+@x' 0
* doio.c: White-space, comment onlyKarl Williamson2022-01-011-9/+9
|
* Add missing fcn return declarationKarl Williamson2022-01-011-0/+1
| | | | This was introduced by 1c267c880abb4d52f0dc23c70636b5f2e80253be.
* Provide asciiopen and asciiopen3 for z/OS ASCII I/OMike Fulton2022-01-011-1/+79
| | | | | | | | | | | | | | | | | | | - Provide an _asciiopen_ and _asciiopen3_ pair of functions for opening files on z/OS. These services do a standard open and then, if the open is successful, update the CCSID of the file descriptor to 819 (ASCII) iff the oflag has ``O_CREAT`` set (e.g. a file is being created). We could consider printing out a warning if a file is untagged - right now this will _work correctly_ if the file in encoded as ASCII (CCSID 819) but will fail if the file is EBCDIC. - Provide a wrapper _Perl_mkstemp_cloexec_ which not only creates a temporary file using mkstemp but will also tag the file as CCSID 819. The tagging is only performed if ``__CHARSET_LIB == 1``, i.e. the code is compiled with -qascii. - Define _PerlIO_open_ and _PerlLIO_open3_ as _asciiopen_ and _asciiopen3_ respectively, when the code is built for ASCII ``#if (__CHARSET_LIB == 1)`` on z/OS ``#if defined(OEMVS)``.
* Remove DOS/DJGPP supportDagfinn Ilmari Mannsåker2021-11-021-6/+0
| | | | | | DJGPP is a port of the GNU toolchain to 32-bit x86 systems running DOS. The last known attempt to build Perl on it was on 5.20, which only got as far as building miniperl.
* fix utime() to set $!/errno when called on a closed handleTony Cook2021-05-241-0/+1
| | | | | | | | My 8334cae65 was intended to fix this, but the test was faulty, and didn't correctly fail. This started showing as a failure on cygwin, with the fixed test it also fails on Linux, so fix doio.c as well.
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-1203/+1203
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* shmwrite: treat the string as bytesTony Cook2020-11-241-1/+1
|
* msgrcv: properly downgrade the receive bufferTony Cook2020-11-241-0/+1
| | | | | If the receive buffer started with SVf_UTF8 on, the received message SV would stay flagged, corrupting the result.
* msgsnd: handle an upgraded MSG parameter correctlyTony Cook2020-11-241-1/+1
|
* fix UTF-8 handling for semop()Tony Cook2020-11-241-1/+1
| | | | | | | | As with semctl(), the UTF-8 flag on the passed in opstring was ignored, which meant that the upgraded version of the same string would cause an error. Just use SvPVbyte().
* io/sem.t: eliminate warningsTony Cook2020-11-241-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | This eliminates some warnings that semctl() (or other *ctl()) calls might generate, and some warnings specific to io/sem.t: - for IPC_STAT and GETALL, the current value of ARG is overwritten so making an undefined value warning for it nonsensical, so don't use SvPV_force(). - for other calls, ARG is either ignored, or in a behaviour introduced in perl 3 (along with the ops), treats the supplied value as an integer which is then converted to a pointer. Rather than warning on an undef value which is most likely to be ignored we treat the undef as zero without the usual warning. - always pass a number for SEMNUM in the test code I didn't try to eliminate warning for non-numeric/undefined SEMNUM, since while we know it isn't used by SETALL, GETALL, IPC_STAT and IPC_SET, it may or may not be used by system defined *ctl() operators such as SEM_INFO and SHM_LOCK on Linux. fixes #17926
* *ctl: test we handle the buffer as bytesTony Cook2020-11-241-2/+2
| | | | | | Previously this had the "unicode bug", an upgraded string would be treated as the encoding of that string, rather than the raw bytes.
* *ctl: ensure the ARG parameter's UTF-8 flag is resetTony Cook2020-11-241-0/+1
| | | | | | | | | If the SV supplied as ARG had the SVf_UTF8 flag on it would be left on, which would effectively corrupt the returned buffer. Only tested with shmctl(), since the other *ctl() functions only have more complex structures with indeterminate types that would require more effort to test.
* autodoc.pl: Specify scn for single-purpose filesKarl Williamson2020-11-061-2/+0
| | | | | | | | Many of the files in perl are for one thing only, and hence their embedded documentation will be for that one thing. By creating a hash here of them, those files don't have to worry about what section that documentation goes under, and so it can be completely changed without affecting them.
* Reorganize perlapiKarl Williamson2020-09-041-1/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* doio.c: Convert to use av_count()Karl Williamson2020-08-191-1/+1
|
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-12/+0
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* Remove Symbian portDagfinn Ilmari Mannsåker2020-07-201-1/+1
| | | | | Also eliminate USE_HEAP_INSTEAD_OF_STACK and SETSOCKOPT_OPTION_VALUE_T, since Symbian was the only user of those.
* Fix a bunch of repeated-word typosDagfinn Ilmari Mannsåker2020-05-221-1/+1
| | | | | Mostly in comments and docs, but some in diagnostic messages and one case of 'or die die'.
* Remove spurious double spaces before open braces in core C codeDagfinn Ilmari Mannsåker2020-04-131-1/+1
|
* doio.c: Use inRANGE macroKarl Williamson2019-12-261-1/+1
|
* Add memCHRs() macro and use itKarl Williamson2019-12-181-1/+1
| | | | | | | This replaces strchr("list", c) calls throughout the core. They don't work properly when 'c' is a NUL, returning the position of the terminating NUL in "list" instead of failure. This could lead to segfaults or even security issues.
* (perl #134221) support append mode for open .. undefTony Cook2019-07-161-0/+15
|
* (perl #122112) a simpler fix for pclose() aborted by a signalTony Cook2019-05-301-1/+11
| | | | | | | | | | | | | | | | | | This change results in a zombie child process for the lifetime of the process, but I think that's the responsibility of the signal handler that aborted pclose(). We could add some magic to retry (and retry and retry) waiting on child process as we rewind (since there's no other way to remove the zombie), but the program has chosen implicitly to abort the wait() done by pclose() and it's best to honor that. If we do choose to retry the wait() we might be blocking an attempt by the process to terminate, whether by exit() or die(). If a program does need more flexible handling there's always pipe()/fork()/exec() and/or the various event-driven frameworks on CPAN.
* foo_cloexec() under PERL_GLOBAL_STRUCT_PRIVATEDavid Mitchell2019-02-191-10/+29
| | | | | | | | | | | | | | | | | | 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.
* (perl #133659) make an in-place edit successful if the exit status is zeroTony Cook2018-11-261-20/+25
| | | | | | | | | | | | | | | | | | | 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.
* (perl #133659) move argvout cleanup to a new functionTony Cook2018-11-261-24/+38
|
* Also work around renameat() kernel bug on GNU/kFreeBSDJames Clarke2018-11-201-2/+2
|
* Use sv_catpvs where appropriate vs sv_catpvKarl Williamson2018-08-061-5/+5
| | | | | This moves calculations definitely to compile time; some optimizing compilers may already do this, but some may not.
* (perl #133314) always close the directory handle on clean upTony Cook2018-08-011-25/+31
| | | | | | | | 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.
* Revert "Revert "make PerlIO handle FD_CLOEXEC""Zefram2018-01-181-27/+23
| | | | | | This reverts commit 523d71b314dc75bd212794cc8392eab8267ea744, reinstating commit 2cdf406af42834c46ef407517daab0734f7066fc. Reversion is not the way to address the porting problem that motivated that reversion.
* Revert "make PerlIO handle FD_CLOEXEC"Abigail2018-01-181-23/+27
| | | | | | | | | | | | | | | | | | | | | 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
* make PerlIO handle FD_CLOEXECZefram2017-12-221-27/+23
| | | | | | 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.
* Perl_my_mkstemp_cloexec() functionZefram2017-12-221-2/+15
| | | | | | 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.
* factor out remaining fcntl F_SETFD callsZefram2017-12-221-5/+3
|
* set FD_CLOEXEC atomically in easy casesZefram2017-12-221-18/+39
| | | | | | | 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.
* *_cloexec() I/O functionsZefram2017-12-221-0/+214
| | | | | | | | | | | | | | | | | 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.
* semicolon-friendly diagnostic controlZefram2017-12-161-6/+6
| | | | | | 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].
* make exec keep its argument list more reliablyZefram2017-12-141-40/+37
| | | | | | | | | | 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].
* (perl #132506) finish the correction to dir_unchanged()Tony Cook2017-12-011-3/+4
| | | | and adjust the error message for renaming the work file
* Fix Windows build following commit 184f90dc41Steve Hay2017-11-301-1/+1
| | | | But t/run/switches.t test 131 still fails, with perl.exe crashing.
* (perl #132506) remove an unneeded argumentTony Cook2017-11-301-8/+8
|