summaryrefslogtreecommitdiffstats
path: root/base/process_util_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Harmonizing ProcessUtil::GetAppOutput on Win/Unixjcampan@chromium.org2009-06-041-8/+9
| | | | | | | | BUG=None TEST=Run the base unit-tests Review URL: http://codereview.chromium.org/119190 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17660 0039d316-1c4b-4281-b951-d872f2087c98
* POSIX: Add a macro for handling EINTR.agl@chromium.org2009-05-011-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* This CL adds a utility method that lets you start a process and block until ↵jcampan@chromium.org2009-04-211-1/+34
| | | | | | | | | | | | | the process terminates, and retrieve what the process printed to the standard output. That util function is needed for the new in-process test framework. It is Windows only for now. BUG=None TEST=Covered by new unit test. Review URL: http://codereview.chromium.org/87008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14135 0039d316-1c4b-4281-b951-d872f2087c98
* Add GetAppOutput function, a better replacement for popen.phajdan.jr@chromium.org2009-04-171-0/+16
| | | | | | | | | | | | 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
* This should make ProcessUtilTest.KillSlowChild not-flaky.phajdan.jr@chromium.org2009-03-161-9/+0
| | | | | | | | | | | | | | | | | There is no need to check process count (which tends to induce flakiness). In fact, we are already checking all important facts: - after checking that process handle is a not-null handle we know that the process started successfully - after WaitForSingleProcess returns true we know that the process finished successfully BUG=8811 Review URL: http://codereview.chromium.org/42224 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11728 0039d316-1c4b-4281-b951-d872f2087c98
* Fixes a build break caused by r10178.hbono@chromium.org2009-02-231-1/+1
| | | | | | | | | | r10178 compares an int value 'written' with a size_t value 'sizeof(num_open_files)' in "base/process_util_unittest.cc" and it caused a compilation error on Mac and Linux. As a quick fix, this change casts the int value 'written' to size_t. TBR=xji Review URL: http://codereview.chromium.org/28019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10179 0039d316-1c4b-4281-b951-d872f2087c98
* Try to fix the tree.evan@chromium.org2009-02-231-1/+1
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10177 0039d316-1c4b-4281-b951-d872f2087c98
* Fix more GCC 4.3 warnings.evan@chromium.org2009-02-231-2/+4
| | | | | | Review URL: http://codereview.chromium.org/27038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10170 0039d316-1c4b-4281-b951-d872f2087c98
* Fix the windows implementation of KillProcess and WaitForSingleProcess to ↵stoyan@chromium.org2009-02-091-0/+3
| | | | | | | | 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
* Rewrite the mac named process iterator:thomasvl@chromium.org2009-02-061-7/+0
| | | | | | | | | | - walk thru only processes for this user. - properly handle walking the data collect. - handle the number of processes increasing between count and data collection. Enable the one unittest the uses the named process iterator. Review URL: http://codereview.chromium.org/20122 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9305 0039d316-1c4b-4281-b951-d872f2087c98
* Implement NamedProcessIterator in base/process_util_mac.mm. Patch by Naokimark@chromium.org2009-02-051-2/+4
| | | | | | | | | 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-0/+18
| | | | | | | | 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
* Call logging::InitLogging. The lack of this was causing some hangs (and ↵erikkay@google.com2009-01-131-2/+4
| | | | | | | | | | | possibly crashes) in ObserverListTest.BUG=6286 This CL has expanded to include some cleanup and refactoring of test_suite and related files, so that this logging change (and other improvements) are applied to all unit tests. Review URL: http://codereview.chromium.org/18003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7977 0039d316-1c4b-4281-b951-d872f2087c98
* Fix TODOs in base/ :phajdan.jr@chromium.org2009-01-131-2/+1
| | | | | | | | | | - switch to FilePath inside CopyDirectory - be less racy in ProcessUtilTest.KillSlowChild Review URL: http://codereview.chromium.org/17013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7948 0039d316-1c4b-4281-b951-d872f2087c98
* Processes take a long time to start if started via ssh,dkegel@google.com2008-12-301-1/+1
| | | | | | | | | | | | | as they now have to connect to the X server (not sure when we added that, or where, but it's happening). In my case, when running ProcessUtilTest.SpawnChild, it takes 1.7 seconds after the main process starts waiting for the child before the child finishes reading from the X server and exits. So raise timeout from one second to five seconds. Review URL: http://codereview.chromium.org/17022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7506 0039d316-1c4b-4281-b951-d872f2087c98
* * On POSIX, make sure we don't leak FDs when launching child Processes.jeremy@chromium.org2008-12-171-2/+75
| | | | | | | | | | | | * 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-75/+2
| | | | | | | 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-2/+75
| | | | | | | | | | | | * 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 Terminate() to the Process object, have RenderProcessHost use this to ↵brettw@google.com2008-11-141-11/+12
| | | | | | | | | | avoid some more Windows specific code. Move Process and SharedMemory into the base namespace (most changes). Review URL: http://codereview.chromium.org/10895 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5446 0039d316-1c4b-4281-b951-d872f2087c98
* Fix compilation error on Windows and link error on Macdkegel@google.com2008-10-311-8/+5
| | | | | | Review URL: http://codereview.chromium.org/8781 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4320 0039d316-1c4b-4281-b951-d872f2087c98
* Port GetProcessCount(), KillProcesses(), and CleanupProcesses().dkegel@google.com2008-10-311-0/+41
| | | | | | | | | Also switch to fork() from vfork(), since strace on my box doesn't support vfork! It's deprecated, anyway. Review URL: http://codereview.chromium.org/8880 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4315 0039d316-1c4b-4281-b951-d872f2087c98
* 1) Add a new MULTIPROCESS_TEST_MAIN macro to store child process namesjeremy@chromium.org2008-10-291-2/+2
| | | | | | | | | | | | | | in a lookup table. Previously we were using different mechanisms on each platform to look up child process names at runtime. This broke on OS X where we strip the symbol table on release executables. 2) Enable process_util_unittest on OS X. Review URL: http://codereview.chromium.org/8864 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4165 0039d316-1c4b-4281-b951-d872f2087c98
* Added linux process utilities and tests.estade@chromium.org2008-10-221-3/+29
| | | | | | Review URL: http://codereview.chromium.org/7202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3715 0039d316-1c4b-4281-b951-d872f2087c98
* Use a more compact license header in source files.license.bot2008-08-241-28/+4
| | | | git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1287 0039d316-1c4b-4281-b951-d872f2087c98
* Add base to the repository.initial.commit2008-07-261-0/+99
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8 0039d316-1c4b-4281-b951-d872f2087c98