| 4038 | |
| 4039 | |
| 4040 | bool wait(const UPID& pid, const Duration& duration) |
| 4041 | { |
| 4042 | process::initialize(); |
| 4043 | |
| 4044 | if (!pid) { |
| 4045 | return false; |
| 4046 | } |
| 4047 | |
| 4048 | // This could result in a deadlock if some code decides to wait on a |
| 4049 | // process that has invoked that code! |
| 4050 | if (__process__ != nullptr && __process__->self() == pid) { |
| 4051 | LOG(ERROR) << "\n**** DEADLOCK DETECTED! ****\nYou are waiting on process " |
| 4052 | << pid << " that it is currently executing."; |
| 4053 | } |
| 4054 | |
| 4055 | if (duration == Seconds(-1)) { |
| 4056 | return process_manager->wait(pid); |
| 4057 | } |
| 4058 | |
| 4059 | bool waited = false; |
| 4060 | |
| 4061 | WaitWaiter waiter(pid, duration, &waited); |
| 4062 | spawn(waiter); |
| 4063 | wait(waiter); |
| 4064 | |
| 4065 | return waited; |
| 4066 | } |
| 4067 | |
| 4068 | |
| 4069 | void filter(Filter* filter) |