@@ -215,20 +215,20 @@ void Process::unprotect_data()
215
215
});
216
216
}
217
217
218
- ErrorOr<NonnullRefPtr<Process>> Process::try_create (RefPtr<Thread>& first_thread, NonnullOwnPtr<KString> name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> cwd , RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
218
+ ErrorOr<NonnullRefPtr<Process>> Process::try_create (RefPtr<Thread>& first_thread, NonnullOwnPtr<KString> name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, RefPtr<Custody> current_directory , RefPtr<Custody> executable, TTY* tty, Process* fork_parent)
219
219
{
220
220
auto space = TRY (Memory::AddressSpace::try_create (fork_parent ? &fork_parent->address_space () : nullptr ));
221
221
auto unveil_tree = UnveilNode { TRY (KString::try_create (" /" sv)), UnveilMetadata (TRY (KString::try_create (" /" sv))) };
222
- auto process = TRY (adopt_nonnull_ref_or_enomem (new (nothrow) Process (move (name), uid, gid, ppid, is_kernel_process, move (cwd ), move (executable), tty, move (unveil_tree))));
222
+ auto process = TRY (adopt_nonnull_ref_or_enomem (new (nothrow) Process (move (name), uid, gid, ppid, is_kernel_process, move (current_directory ), move (executable), tty, move (unveil_tree))));
223
223
TRY (process->attach_resources (move (space), first_thread, fork_parent));
224
224
return process;
225
225
}
226
226
227
- Process::Process (NonnullOwnPtr<KString> name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, RefPtr <Custody> cwd , RefPtr<Custody> executable, TTY* tty, UnveilNode unveil_tree)
227
+ Process::Process (NonnullOwnPtr<KString> name, UserID uid, GroupID gid, ProcessID ppid, bool is_kernel_process, NonnullRefPtr <Custody> current_directory , RefPtr<Custody> executable, TTY* tty, UnveilNode unveil_tree)
228
228
: m_name(move(name))
229
229
, m_is_kernel_process(is_kernel_process)
230
230
, m_executable(move(executable))
231
- , m_cwd (move(cwd ))
231
+ , m_current_directory (move(current_directory ))
232
232
, m_tty(tty)
233
233
, m_unveiled_paths(move(unveil_tree))
234
234
, m_wait_blocker_set(*this )
@@ -528,11 +528,13 @@ siginfo_t Process::wait_info() const
528
528
return siginfo;
529
529
}
530
530
531
- Custody& Process::current_directory ()
531
+ NonnullRefPtr< Custody> Process::current_directory ()
532
532
{
533
- if (!m_cwd)
534
- m_cwd = VirtualFileSystem::the ().root_custody ();
535
- return *m_cwd;
533
+ return m_current_directory.with ([&](auto & current_directory) -> NonnullRefPtr<Custody> {
534
+ if (!current_directory)
535
+ current_directory = VirtualFileSystem::the ().root_custody ();
536
+ return *current_directory;
537
+ });
536
538
}
537
539
538
540
ErrorOr<NonnullOwnPtr<KString>> Process::get_syscall_path_argument (Userspace<char const *> user_path, size_t path_length)
@@ -629,7 +631,6 @@ void Process::finalize()
629
631
m_fds.with_exclusive ([](auto & fds) { fds.clear (); });
630
632
m_tty = nullptr ;
631
633
m_executable = nullptr ;
632
- m_cwd = nullptr ;
633
634
m_arguments.clear ();
634
635
m_environment.clear ();
635
636
0 commit comments