summary refs log tree commit diff stats
path: root/lib/system/io.nim
Commit message (Collapse)AuthorAgeFilesLines
* move since from inclrtl to std/private/since (#14188)hlaaftana2020-05-021-0/+1
| | | | * move since from inclrtl to std/private/since * move since import in system below for HCR
* change 'iff' to 'if' to stop "corrections" once and for all (#14182)Miran2020-05-011-4/+4
|
* Make file descriptors from stdlib non-inheritable by default (#13201)alaviss2020-04-201-5/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * io: make file descriptors non-inheritable by default This prevents file descriptors/handles leakage to child processes that might cause issues like running out of file descriptors, or potential security issues like leaking a file descriptor to a restricted file. While this breaks backward compatibility, I'm rather certain that not many programs (if any) actually make use of this implementation detail. A new API `setInheritable` is provided for the few that actually want to use this functionality. * io: disable inheritance at file creation time for supported platforms Some platforms provide extension to fopen-family of functions to allow for disabling descriptor inheritance atomically during File creation. This guards against possible leaks when a child process is spawned before we managed to disable the file descriptor inheritance (ie. in a multi-threaded program). * net, nativesockets: make sockets non inheritable by default With this commit, sockets will no longer leak to child processes when you don't want it to. Should solves a lot of "address in use" that might occur when your server has just restarted. All APIs that create sockets in these modules now expose a `inheritable` flag that allow users to toggle inheritance for the resulting sockets. An implementation of `setInheritance()` is also provided for SocketHandle. While atomically disabling inheritance at creation time is supported on Windows, it's only implemented by native winsock2, which is too much for now. This support can be implemented in a future patch. * posix: add F_DUPFD_CLOEXEC This command duplicates file descriptor with close-on-exec flag set. Defined in POSIX.1-2008. * ioselectors_kqueue: don't leak file descriptors File descriptors internally used by ioselectors on BSD/OSX are now shielded from leakage. * posix: add O_CLOEXEC This flag allows file descriptors to be open() with close-on-exec flag set atomically. This flag is specified in POSIX.1-2008 * tfdleak: test for selectors leakage Also simplified the test by using handle-type agnostic APIs to test for validity. * ioselectors_epoll: mark all fd created close-on-exec File descriptors from ioselectors should no longer leaks on Linux. * tfdleak: don't check for selector leakage on Windows The getFd proc for ioselectors_select returns a hardcoded -1 * io: add NoInheritFlag at compile time * io: add support for ioctl-based close-on-exec This allows for the flag to be set/unset in one syscall. While the performance gains might be negliable, we have one less failure point to deal with. * tfdleak: add a test for setInheritable * stdlib: add nimInheritHandles to restore old behaviors * memfiles: make file handle not inheritable by default for posix * io: setInheritable now operates on OS file handle On Windows, the native handle is the only thing that's inheritable, thus we can assume that users of this function will already have the handle available to them. This also allows users to pass down file descriptors from memfiles on Windows with ease, should that be desired. With this, nativesockets.setInheritable can be made much simpler. * changelog: clarify * nativesockets: document setInheritable return value * posix_utils: atomically disable fd inheritance for mkstemp
* fix #13829 (#13831)Timothee Cour2020-04-011-1/+1
|
* __stderrp and friends are only on FreeBSD & DragonFlyBSD. (#13735)Euan2020-03-231-1/+1
|
* fix #9634 don't crash on execCmdEx/readLine when inside gdb/lldb (#13232)Timothee Cour2020-02-111-2/+15
| | | | | | | | * fix #9634 debugging a program using execCmdEx now works * only apply EINTR to c_gets for now This reverts commit c0f5305b5a0b46983dfd27e3d77ecbf4f8744dcc.
* [backport] fix #13352narimiran2020-02-071-0/+3
|
* enable testing -d:nimHasLibFFI mode (#13091)Timothee Cour2020-02-041-1/+1
|
* fix stdout(etc) for emscriptenTimothee Cour2020-01-281-3/+4
|
* Added 'ansic' os support for minimal (embedded) targets (#13088)Ico Doornekamp2020-01-151-2/+2
| | | | | | | | * os:any implementation * os:asny: omit flock/funlock calls in echoBinSafe * Disabled default "unhandled expection" reporting for `--os:any` to reduce code size. Added unhandledExceptionHook instead which can be used to get a notification from Nim and handle it from the application.
* VM FFI: write(stderr, msg) and fprintf(cstderr, msg) now work at CT (#13083)Timothee Cour2020-01-121-3/+8
|
* [backport] system/io.nim fix wrong documentation comment [ci skip]narimiran2020-01-101-2/+2
|
* fixes #13013, reverts previous changes to readLines() (#13036) [backport]cooldome2020-01-051-3/+5
| | | | | | | * Revert "remove default argument for readLines (#12807) [backport]" This reverts commit c949b81efdeb08b38224e1678ad140b7b7663b15.
* remove default argument for readLines (#12807) [backport]cooldome2020-01-021-3/+3
|
* minor refactoringsAndreas Rumpf2019-12-271-9/+9
|
* added 'since' template for further stdlib additionsAndreas Rumpf2019-11-071-1/+1
|
* introduce csize_t instead of fixing csize (#12497)Arne Döring2019-10-311-9/+9
|
* fix several typos in documentation and comments (#12553)Nindaleth2019-10-301-2/+2
|
* fix deprecation warnings related to Int128 (#12474)Miran2019-10-281-1/+1
| | | | | | | | * semfold: fix deprecation warnings related to Int128 * semmagic: fix deprecation warnings related to Int128 * system/io: remove unneeded conversion of TaintedString to itself
* Revert "Fixes #12187 (#12321)" (#12447)Andreas Rumpf2019-10-181-11/+3
| | | This reverts commit 00c31e87660d9db813871f5aa23661bf6b9bbdcb.
* fix a few dead links and a missing sentence in documentation (#12387)Nindaleth2019-10-081-3/+3
|
* fixes #12315 [backport]; refs #12314 (#12385)Andreas Rumpf2019-10-081-0/+6
|
* Fixes #12187 (#12321)Clyybber2019-10-081-3/+11
| | | | | | * Fixes #12187 * Point to fork of compactdict Since the original repo is now archived / read-only
* `system.writeFile` has been overloaded to also support `openarray[byte]` ↵zah2019-10-021-0/+12
| | | | | | (#12313)
* consistent floating point output (#12219)Andreas Rumpf2019-09-201-2/+9
| | | | | * unify float printing * makes tests green
* Add -d:androidNDK to fix echo on Android NDK builds. (#12203)treeform2019-09-171-19/+32
| | | | | | | | * Add -d:echoToAndroidLog to fix echo. * Change to androidNDK and add docs. * Some word changes to docs.
* more enhancements for #11618 (#11976)Andreas Rumpf2019-08-181-2/+25
| | | | | | * finish the Windows IO layer changes; refs #11618 * added system.getOsFileHandle which is less error-prone on Windows * make tests green again
* fixes #11618 (#11969)Andreas Rumpf2019-08-171-4/+28
|
* fixes #11801Araq2019-08-161-1/+1
|
* styleCheck: make the compiler and large parts of the stdlib compatible with ↵Araq2019-07-101-8/+8
| | | | --styleCheck:error
* fixes #11618 (#11631)Andreas Rumpf2019-07-011-1/+1
|
* Compiler plugin for implementing incremental computation in user space (#10819)cooldome2019-04-111-0/+19
| | | | | | | | | | This plugin provides essential building block for implementing incremental computations in your programs. The idea behind incremental computations is that if you do the same calculation multiple times but with slightly different inputs you don't have to recompute everything from scratch. Also you don't want to adopt special algorithms either, you would like to write your code in standard from scratch manner and get incrementality for free when it is possible. The plugin computes the digest of the proc bodies, recursively hashing all called procs as well . Such digest with the digest of the argument values gives a good "name" for the result. Terminology loosely follows paper "Incremental Computation with Names" link below. It works well if you have no side effects in your computations. If you have global state in your computations then you will need problem specific workarounds to represent global state in set of "names" . SideEffect tracking in Nim also useful in this topic. Classical examples: Dashboard with ticking data. New data arrives non stop and you would like to update the dashboard recomputing only changed outputs. Excel spreadsheet where user changes one cell and you would like to recompute all cells that are affected by the change, but do not want to recompute every cell in the spreadsheet.
* further system.nim cleanupsAndreas Rumpf2019-02-061-0/+8
|
* system refactorings (#10559)Andreas Rumpf2019-02-061-0/+640
* move IO subsystem into its own module; refs #10385 * make standalone test compile again * make C++ examples compile again * make more tests green * make sysAssert and gcAssert work again