summaryrefslogtreecommitdiffstats
path: root/base/process_util_posix.cc
Commit message (Collapse)AuthorAgeFilesLines
* Linux: Use _exit() instead of exit() in the child after fork() in failure ↵mdm@chromium.org2009-07-231-0/+5
| | | | | | | | | | | conditions. TEST=none BUG=none Review URL: http://codereview.chromium.org/159275 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21418 0039d316-1c4b-4281-b951-d872f2087c98
* Linux/Mac: Use _exit() instead of exit() in the child after fork() in ↵mdm@chromium.org2009-07-221-3/+3
| | | | | | | | | | | failure conditions. BUG=17329 TEST=none Review URL: http://codereview.chromium.org/159201 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21294 0039d316-1c4b-4281-b951-d872f2087c98
* Fix KillProcess so it doesn't report everything as a failure.stuartmorgan@chromium.org2009-07-131-4/+11
| | | | | | | | BUG=none TEST=UI tests on Mac should no longer all log that kills are failing. Review URL: http://codereview.chromium.org/155297 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20566 0039d316-1c4b-4281-b951-d872f2087c98
* Fix tools/valgrind/chrome_tests.sh to always use --log-file optiondank@chromium.org2009-07-071-0/+6
| | | | | | | | | | | | | | | so fork() doesn't corrupt log files; lets --generate_suppressions work even with the hacky valgrind fix that makes anything but --log-file crash on child of fork(). Also avoid killing user desktop session if zygote dies! BUG=none, but related to fix for http://crbug.com/15771 TEST=patch valgrind with fork workaround; sh tools/valgrind/chrome_tests.sh --generate_suppressions -t ui logs you out on linux without this. Review URL: http://codereview.chromium.org/155130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20024 0039d316-1c4b-4281-b951-d872f2087c98
* Consistently use int64 for integers holding number of milliseconds.phajdan.jr@chromium.org2009-06-171-6/+6
| | | | | | | | | | This applies only to things which use TimeDelta::InMilliseconds, because it returns int64. Before this patch callers static_casted that to int, and after this patch they use the returned value as int64. Review URL: http://codereview.chromium.org/126279 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18626 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: read subprocess output before waiting for termination.agl@chromium.org2009-06-101-8/+7
| | | | | | | | | | | | | Previously, GetAppOutput was designed only for fuser. However, it appears that Mac is using it to read the output of ps: which outputs rather more. In this case, ps can fill up the pipe buffer while we are waiting for it to exit, leading to deadlock depending on how many other process are running on the system at the time. http://codereview.chromium.org/118514 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18068 0039d316-1c4b-4281-b951-d872f2087c98
* CloseSuperfluousFiles shouldn't close the directory it's reading fromdkegel@google.com2009-06-071-0/+3
| | | | | | | | | BUG=none TEST=none (found with strace while running e.g. ProcessUtilTest.FDRemapping) Review URL: http://codereview.chromium.org/115720 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17847 0039d316-1c4b-4281-b951-d872f2087c98
* Fixes a bug where we were inadvertently closing Valgrind-owned FDsrohitrao@chromium.org2009-05-061-23/+30
| | | | | | | | | | | when running under Valgrind. TEST=None http://crbug.com/11412 Review URL: http://codereview.chromium.org/108042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15414 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: Add a macro for handling EINTR.agl@chromium.org2009-05-011-25/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On POSIX systems, system calls can be interrupted by signals. In this case, they'll return EINTR, indicating that the system call needs to be restarted. (The situation is a little more complicated than this with SA_RESTART, but you can read man 7 signal if you like.) The short of it is that you need to catch EINTR and restart the call for these system calls: * read, readv, write, writev, ioctl * open() when dealing with a fifo * wait* * Anything socket based (send*, recv*, connect, accept etc) * flock and lock control with fcntl * mq_ functions which can block * futex * sem_wait (and timed wait) * pause, sigsuspend, sigtimedwait, sigwaitinfo * poll, epoll_wait, select and 'p' versions of the same * msgrcv, msgsnd, semop, semtimedop * close (although, on Linux, EINTR won't happen here) * any sleep functions (careful, you need to handle this are restart with different arguments) We've been a little sloppy with this until now. This patch adds a macro for dealing with this and corrects every case of these system calls (that I found). The macro is HANDLE_EINTR in base/eintr_wrapper.h. It's safe to include on Windows and is a no-op there. On POSIX, it uses GCC magic to return the correct type based on the expression and restarts the system call if it throws EINTR. And you can use it like: HANDLE_EINTR(close(fd)); Or: ssize_t bytes_read = HANDLE_EINTR(read(fd, buffer, len)); *BEWARE* that it will evaluate the argument multiple times, so this is not safe: HANDLE_EINTR(close(FireMissiles())); http://groups.google.com/group/chromium-dev/browse_thread/thread/41a35b2a457d73a0 http://codereview.chromium.org/100225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15102 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: Add code for shuffling file descriptors.agl@chromium.org2009-04-301-13/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | When forking a child process, one often wants to move existing file descriptors to well known locations (stdout, stderr etc). However, this is a process bedeviled with corner cases. Consider the case where you open two file descriptors, get assigned fds 1 and 0 for them and wish to shuffle them so that they end up in slots 0 and 1. Our current code fails in this case. We also have a problem where we're currently trying to mark file descriptors as close-on-exec rather than closing them in the child process. This is inherently broken in a multithreaded process where another thread can open a file descriptor and race the loop which is trying to mark them. Thus, on Linux we switch to close-after-fork where we known that no other threads exist in the process. On Mac, the code is sufficiently different that this simple fix isn't applicable and one of the Mac folks will need to take a look. http://codereview.chromium.org/100127 BUG=11174 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14978 0039d316-1c4b-4281-b951-d872f2087c98
* Make task_manager_resource_providers.cc compile on POSIX.phajdan.jr@chromium.org2009-04-301-0/+6
| | | | | | | | TEST=Make sure that the task manager isn't obviously broken on Windows. Review URL: http://codereview.chromium.org/93067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14934 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: don't spawn zombies.agl@chromium.org2009-04-281-10/+23
| | | | | | | | | http://codereview.chromium.org/93147 BUG=9401 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14705 0039d316-1c4b-4281-b951-d872f2087c98
* Revert r14620 which was a rollback of r14549 and r14508. Thistc@google.com2009-04-271-2/+7
| | | | | | | | | | | | change re-enables the ui tests. Since jam re-enabled some tests, I had to #ifdef around 4 tests that are not shutting down cleanly on linux. It looks like we have renderers that aren't shutting down properly (pegged at 100% cpu). Review URL: http://codereview.chromium.org/100061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14680 0039d316-1c4b-4281-b951-d872f2087c98
* Speculatively roll back r14549 and r14508. The chrome browsertc@google.com2009-04-271-7/+2
| | | | | | | | | | | | process is pegged at 100% cpu after ui_tests has exited. Seeing if this is the cause. Will re-roll forward if it's not. TBR=estade Review URL: http://codereview.chromium.org/100047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14620 0039d316-1c4b-4281-b951-d872f2087c98
* Port unload_uitest.cc and enable some of the tests on linux.estade@chromium.org2009-04-241-2/+7
| | | | | | | | Make WaitForSingleProcess respect base::kNoTimeout (which is equivalent to INFINITE on windows). Review URL: http://codereview.chromium.org/99008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14508 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "POSIX: Don't spawn zombies." (r14488)agl@chromium.org2009-04-241-14/+3
| | | | | | | | Something else is trying to reap children in the ui_tests and causing a mess. Reverting since it's a Friday night. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14499 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: Don't spawn zombies.agl@chromium.org2009-04-241-3/+14
| | | | | | | | TEST=Navigate to several different sites and check that no Chrome zombies are roaming around. BUG=9401 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14488 0039d316-1c4b-4281-b951-d872f2087c98
* Get rid of variable length arrays.willchan@chromium.org2009-04-241-2/+2
| | | | | | Review URL: http://codereview.chromium.org/92005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14440 0039d316-1c4b-4281-b951-d872f2087c98
* More solid detection of browser process in chrome_process_util_linux.cc:phajdan.jr@chromium.org2009-04-211-2/+8
| | | | | | | | | | | | | | | | - use GetAppOutput instead of popen - make unexpected conditions fatal (otherwise the tests using this code would mistakenly assume that there is no running browser process) Also add a constant for SingletonSocket. Make necessary adjustments to GetAppOutput - ignore stderr (because fuser prints the file name to stderr and having stderr in |output| would require more parsing). Review URL: http://codereview.chromium.org/77031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14091 0039d316-1c4b-4281-b951-d872f2087c98
* Add GetAppOutput function, a better replacement for popen.phajdan.jr@chromium.org2009-04-171-0/+68
| | | | | | | | | | | | It will replace popen call in chrome_process_util_linux. I don't see much benefit in having a Windows implementation (not many useful programs you can launch and get output), so POSIX-only. Review URL: http://codereview.chromium.org/67226 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13920 0039d316-1c4b-4281-b951-d872f2087c98
* Make OpenProcessHandle report an error when it couldn't open the handle.phajdan.jr@chromium.org2009-04-031-2/+3
| | | | | | | | One more step to land http://codereview.chromium.org/54003 (chrome_process_util). Review URL: http://codereview.chromium.org/62004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13086 0039d316-1c4b-4281-b951-d872f2087c98
* Use portable typedef for PIDs (process IDs).phajdan.jr@chromium.org2009-04-011-3/+3
| | | | | | | | | This is a preparation to land http://codereview.chromium.org/54003, which replaces chrome_process_filter with more portable chrome_process_util. Review URL: http://codereview.chromium.org/57062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12948 0039d316-1c4b-4281-b951-d872f2087c98
* Removed unneeded includes of base/scoped_ptr.h. Reduce usage from ~800 files ↵thestig@chromium.org2009-03-131-0/+1
| | | | | | | | to ~400. Review URL: http://codereview.chromium.org/46039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11651 0039d316-1c4b-4281-b951-d872f2087c98
* Make CrashAwareSleep more accurate on POSIX (checking if the process exists).phajdan.jr@chromium.org2009-03-061-8/+20
| | | | | | Review URL: http://codereview.chromium.org/39185 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11103 0039d316-1c4b-4281-b951-d872f2087c98
* Make startup_tests build and run on Linux (except reference tests).phajdan.jr@chromium.org2009-03-051-1/+1
| | | | | | Review URL: http://codereview.chromium.org/27240 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10978 0039d316-1c4b-4281-b951-d872f2087c98
* Make UITest::CrashAwareSleep portable.phajdan.jr@chromium.org2009-03-041-4/+20
| | | | | | Review URL: http://codereview.chromium.org/40119 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10916 0039d316-1c4b-4281-b951-d872f2087c98
* Fix the windows implementation of KillProcess and WaitForSingleProcess to ↵stoyan@chromium.org2009-02-091-1/+1
| | | | | | | | not close the process handle that they do not own. Review URL: http://codereview.chromium.org/24004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9400 0039d316-1c4b-4281-b951-d872f2087c98
* Make ResourceMessageFilter compile on Mac. It stubs out a substantial part ofbrettw@google.com2009-02-061-0/+11
| | | | | | | | | the printing. It creates new base functions for converting PIDs to handles, and then closing them (since Windows requires this). This also fixes the formatting of image_util. Review URL: http://codereview.chromium.org/20109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9291 0039d316-1c4b-4281-b951-d872f2087c98
* Implement NamedProcessIterator in base/process_util_mac.mm. Patch by Naokimark@chromium.org2009-02-051-0/+57
| | | | | | | | | Takano <takano.naoki@gmail.com> Review URL: http://codereview.chromium.org/18192 Review URL: http://codereview.chromium.org/21097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9263 0039d316-1c4b-4281-b951-d872f2087c98
* Add routine to close file descriptors on execjeremy@chromium.org2009-01-291-14/+43
| | | | | | | | for linux and mac. See BUG 6598. Review URL: http://codereview.chromium.org/18801 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8892 0039d316-1c4b-4281-b951-d872f2087c98
* Revert r8560 due to broken interactive_ui_testsmark@chromium.org2009-01-231-4/+0
| | | | | | Review URL: http://codereview.chromium.org/18722 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8570 0039d316-1c4b-4281-b951-d872f2087c98
* Porting in chrome/phajdan.jr@chromium.org2009-01-231-0/+4
| | | | | | Review URL: http://codereview.chromium.org/18446 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8560 0039d316-1c4b-4281-b951-d872f2087c98
* Share DidProcessCrash between Linux and Mac.deanm@chromium.org2009-01-211-0/+25
| | | | | | | Review URL: http://codereview.chromium.org/18447 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8363 0039d316-1c4b-4281-b951-d872f2087c98
* Port crash_cache tool to Linux.phajdan.jr@chromium.org2009-01-131-0/+20
| | | | | | Review URL: http://codereview.chromium.org/17353 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7939 0039d316-1c4b-4281-b951-d872f2087c98
* Move KillProcess from linux to posix so it can be used on the Mac.dkegel@google.com2009-01-051-0/+25
| | | | | | | | This was originally part of http://codereview.chromium.org/16207 and is broken out here so I can get the small stuff out of the way. Review URL: http://codereview.chromium.org/16498 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7554 0039d316-1c4b-4281-b951-d872f2087c98
* * On POSIX, make sure we don't leak FDs when launching child Processes.jeremy@chromium.org2008-12-171-0/+18
| | | | | | | | | | | | * Add a facility to LaunchProcess() to remap a given FD into a child process. This change is needed for 2 reasons: 1)We want to use a socketpair() for IPC, the child process needs a known FD # for it's side of the socket. 2)The OS X Sandbox doesn't close FDs. Review URL: http://codereview.chromium.org/14497 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7175 0039d316-1c4b-4281-b951-d872f2087c98
* Reverting 7156.ojan@google.com2008-12-171-18/+0
| | | | | | | Broke the build. Review URL: http://codereview.chromium.org/15402 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7159 0039d316-1c4b-4281-b951-d872f2087c98
* * On POSIX, make sure we don't leak FDs when launching child Processes.jeremy@chromium.org2008-12-171-0/+18
| | | | | | | | | | | | * Add a facility to LaunchProcess() to remap a given FD into a child process. This change is needed for 2 reasons: 1)We want to use a socketpair() for IPC, the child process needs a known FD # for it's side of the socket. 2)The OS X Sandbox doesn't close FDs. Review URL: http://codereview.chromium.org/14497 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7156 0039d316-1c4b-4281-b951-d872f2087c98
* * Add timeout support to POSIX WaitForSingleProcess()jeremy@chromium.org2008-12-081-5/+42
| | | | | | | | * Unify Linux & Mac implementations of WaitForSingleProcess() Review URL: http://codereview.chromium.org/12969 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6526 0039d316-1c4b-4281-b951-d872f2087c98
* * Add timeout support to POSIX WaitForSingleProcess()jeremy@chromium.org2008-12-051-1/+19
| | | | | | | | * Unify Linux & Mac implementations of WaitForSingleProcess() Review URL: http://codereview.chromium.org/12969 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6416 0039d316-1c4b-4281-b951-d872f2087c98
* Quick touchup requested by revieweravi@google.com2008-12-021-2/+1
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6238 0039d316-1c4b-4281-b951-d872f2087c98
* Implement GetCPUUsage; it was causing link errors because of its absence on ↵avi@google.com2008-12-021-0/+53
| | | | | | | | the Mac, so we'll implement it for everyone. Review URL: http://codereview.chromium.org/12869 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6221 0039d316-1c4b-4281-b951-d872f2087c98
* Move process utils into the base namespace (fix build bustage).brettw@google.com2008-11-141-2/+2
| | | | | | Review URL: http://codereview.chromium.org/10736 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5447 0039d316-1c4b-4281-b951-d872f2087c98
* Port parts of base/process_util to Linux.evanm@google.com2008-10-141-0/+14
| | | | | | | | Review URL: http://codereview.chromium.org/6492 Patch from Paweł Hajdan jr <phajdan.jr@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3363 0039d316-1c4b-4281-b951-d872f2087c98
* Enforce Terminate on Heap Corruption in most of our executable on Windows XP ↵maruel@google.com2008-09-241-0/+4
| | | | | | | | | | | SP3 or Vista. This won't submit the crash dump but it's still better than nothing. Fix broken alignment on test_shell_main.cc. Review URL: http://codereview.chromium.org/3105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2546 0039d316-1c4b-4281-b951-d872f2087c98
* * Change output of trace_event log to JSON to enable easier integration with ↵erikkay@google.com2008-09-181-0/+4
| | | | | | | | | | | | visualization UI. * Simple (manual) trace visualizer with some sample data. * a few more trace events * add process_util function for current process handle Review URL: http://codereview.chromium.org/3086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2381 0039d316-1c4b-4281-b951-d872f2087c98
* Fix process_util_posix.ccmmentovai@google.com2008-08-271-1/+2
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1442 0039d316-1c4b-4281-b951-d872f2087c98
* Stub out a few things into process_util_posix.deanm@google.com2008-08-271-0/+26
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1441 0039d316-1c4b-4281-b951-d872f2087c98