Commit graph

37 commits

Author SHA1 Message Date
ridiculousfish
4899086b3c Big fat refactoring of how redirections work. In fish 1.x and 2.0.0, the redirections for a process were flattened into a big list associated with the job, so there was no way to tell which redirections applied to each process. Each process therefore got all the redirections associated with the job. See https://github.com/fish-shell/fish-shell/issues/877 for how this could manifest.
With this change, jobs only track their block-level redirections. Process level redirections are correctly associated with the process, and at exec time we stitch them together (block, pipe, and process redirects).

This fixes the weird issues where redirects bleed across pipelines (like #877), and also allows us to play with the order in which redirections are applied, since the final list is constructed right before it's needed.  This lets us put pipes after block level redirections but before process level redirections, so that a 2>&1-type redirection gets picked up after the pipe, i.e. it should fix https://github.com/fish-shell/fish-shell/issues/110

This is a significant change. The tests all pass. Cross your fingers.
2013-08-19 18:06:24 -07:00
ridiculousfish
fb89e1a26f Reenable free_redirected_fds_from_pipes. 2013-08-19 18:06:24 -07:00
ridiculousfish
e849beabba Initial work towards various IO cleanups with an eye to fixing https://github.com/fish-shell/fish-shell/issues/110 2013-08-19 18:06:24 -07:00
ridiculousfish
a8e92639af Cleanup and simplify null_terminated_array_t and its clients 2013-02-22 16:22:56 -08:00
ridiculousfish
ad8d68dd43 Make subcommands modify $status, and make builtin_set not modify status unless it fails
https://github.com/fish-shell/fish-shell/issues/547
https://github.com/fish-shell/fish-shell/issues/214
2013-01-31 15:57:08 -08:00
ridiculousfish
f850c021b7 Merge branch 'split-io' of git://github.com/xiaq/fish-shell into xiaq-split-io 2013-01-18 16:17:31 -08:00
Jan Kanis
c6e5987480 add a JOIN_THREADS_BEFORE_FORK preprocessor flag to help debug locking problems 2013-01-17 13:14:05 +01:00
Cheer Xiao
57ef5289fe Make is_input a member of io_pipe_t 2013-01-17 15:55:06 +08:00
Cheer Xiao
00b6431ad9 Split out io_pipe_t, let io_buffer_t inherit it 2013-01-17 15:55:05 +08:00
Cheer Xiao
4b6bd7cae5 Split out io_file_t 2013-01-17 15:55:05 +08:00
Cheer Xiao
6f35792c74 Split out io_fd_t 2013-01-17 14:58:53 +08:00
Jan Kanis
af9d611847 use debug_safe in postfork do_builtin_io. Closes #495 2013-01-12 19:13:45 +01:00
ridiculousfish
9d6c4fa678 Make do_builtin_io multi-fork safe, moved it to postfork.cpp
Addresses https://github.com/fish-shell/fish-shell/issues/495
2013-01-11 15:09:53 -08:00
Cheer Xiao
b66233de78 Revert "Revert shared_ptr<io_data_t> changes until kinks are ironed out"
This reverts commit 77f1b1f0fe.
2013-01-11 14:18:10 -08:00
ridiculousfish
c70e92e98d Don't call strerror or perror after fork, it's unsafe. Added safe_strerror and safe_perror replacements.
Fixes https://github.com/fish-shell/fish-shell/issues/495
2013-01-09 17:06:20 -08:00
ridiculousfish
77f1b1f0fe Revert shared_ptr<io_data_t> changes until kinks are ironed out
https://github.com/fish-shell/fish-shell/pull/487

Revert "Merge branch 'oo-io' of git://github.com/xiaq/fish-shell into xiaq-oo-io"

This reverts commit f3c8f535a4, reversing
changes made to b02f6cf3bc.

Also reverts ac023f7588 and a79d3c680c
2013-01-04 02:05:30 -08:00
ridiculousfish
ac023f7588 Replace some shared_ptrs with const shared_ptr &. Don't use shared_ptr in postfork.cpp. Eliminate copy constructor in io_data_t. Simplify some other uses of shared_ptr<io_data_t> 2013-01-04 00:22:12 -08:00
Cheer Xiao
a9ada13a23 Use shared_ptr to manage io_data_t*. 2012-12-31 23:54:17 +08:00
ridiculousfish
26678682ca Fix indentation of switch statements 2012-11-19 00:31:03 -08:00
ridiculousfish
9992b8eb0e Apply new indentation, brace, and whitespace style 2012-11-18 16:30:30 -08:00
Łukasz Niemier
47df1ae40a Remove trailing whitespaces and change tabs to spaces 2012-11-18 11:23:22 +01:00
ridiculousfish
8c24d49c73 Removed unused commented out code and fixed some indentation 2012-11-04 15:47:55 -08:00
ridiculousfish
5e371e8fe7 Don't use posix_spawn for commands that need to be put into foreground to avoid a race
Fix for race where a command's output may not be fully drained
2012-11-04 15:45:52 -08:00
ridiculousfish
425afa63ce Don't use posix_spawn when file redirections are involved (except /dev/null) because the error handling is too difficult
Fix exec to correctly handle the case where a pid could not be created due to posix_spawn failing
Should fix https://github.com/fish-shell/fish-shell/issues/364
2012-10-29 01:45:51 -07:00
ridiculousfish
f5d4e3f94c Reintroduce IO transmorgrification (yuck) to fix problems with fish_config and complicated IO redirections 2012-08-22 13:41:21 -07:00
ridiculousfish
26857fabdc Real fix for https://github.com/fish-shell/fish-shell/issues/278
We forget to set the parent group ID in posix_spawn (!)
2012-08-15 17:32:57 -07:00
ridiculousfish
61686aff34 Adopt posix_spawn (!)
Rewrite IO chains to be a vector of pointers, instead of a linked list
Removed io_transmogrify
2012-08-15 00:57:56 -07:00
ridiculousfish
00d3e18780 Fix compile error (oops) 2012-03-27 19:10:21 -07:00
ridiculousfish
a62f300753 Make the color picker cell borders appear correctly in Firefox 2012-03-27 19:00:03 -07:00
ridiculousfish
14a35e7c21 Flip the switch to stop draining threads before exec (!) 2012-03-09 11:28:24 -08:00
ridiculousfish
d173bb6e0a A bunch of changes working towards eliminating all memory allocation after fork() 2012-03-08 23:21:07 -08:00
ridiculousfish
36fe1e4a46 Some initial work towards cutting down the number of fork calls we do 2012-03-06 15:12:37 -08:00
ridiculousfish
191221eec5 Final cleanup of io_data_t now that I recognize the bizarre way in which it shares output buffers (not sure how this ever worked before) 2012-03-04 02:35:30 -08:00
Peter Ammon
8b26d0104c Some initial changes to use CLO_EXEC, with an eye towards some day using it correctly. 2012-03-02 00:27:40 -08:00
ridiculousfish
8ada404c5f More work towards improving relationship between multithreading and fork 2012-02-29 16:14:51 -08:00
ridiculousfish
909d24cde6 More work on improving interaction between fork and pthreads. Added null_terminated_array_t class. 2012-02-29 16:14:51 -08:00
ridiculousfish
4e912ef83d Added postfork 2012-02-29 16:14:51 -08:00