diff --git a/fs/procfs/procfs_vnops.cc b/fs/procfs/procfs_vnops.cc index 4d94966f19..3afccd3435 100644 --- a/fs/procfs/procfs_vnops.cc +++ b/fs/procfs/procfs_vnops.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include "fs/pseudofs/pseudofs.hh" @@ -177,7 +178,7 @@ procfs_mount(mount* mp, const char *dev, int flags, const void* data) auto* root = new pseudo_dir_node(vp->v_ino); root->add("self", self); - root->add("0", self); // our standard pid + root->add(std::to_string(OSV_PID), self); // our standard pid root->add("mounts", inode_count++, procfs_mounts); root->add("sys", sys); diff --git a/include/osv/pid.h b/include/osv/pid.h new file mode 100644 index 0000000000..91efb927e5 --- /dev/null +++ b/include/osv/pid.h @@ -0,0 +1,7 @@ + +#ifndef _OSV_PID_H_ +#define _OSV_PID_H + +#define OSV_PID 2 + +#endif diff --git a/libc/signal.cc b/libc/signal.cc index 57cad35a8a..aaf8f62a46 100644 --- a/libc/signal.cc +++ b/libc/signal.cc @@ -18,6 +18,7 @@ #include #include #include +#include using namespace osv::clock::literals; @@ -325,17 +326,13 @@ int kill(pid_t pid, int sig) sig, strsignal(sig)); osv::poweroff(); } else if(!is_sig_ign(signal_actions[sig])) { - if ((pid == 0) || (pid == -1)) { - // That semantically means signalling everybody (or that, or the - // user did getpid() and got 0, all the same. So we will signal + if ((pid == OSV_PID) || (pid == 0) || (pid == -1)) { + // This semantically means signalling everybody. So we will signal // every thread that is waiting for this. // // The thread does not expect the signal handler to still be delivered, // so if we wake up some folks (usually just the one waiter), we should // not continue processing. - // - // FIXME: Maybe it could be a good idea for our getpid() to start - // returning 1 so we can differentiate between those cases? if (wake_up_signal_waiters(sig)) { return 0; } @@ -482,7 +479,7 @@ void itimer::work() } else { _due = _no_alarm; } - kill(0, _signum); + kill(getpid(), _signum); if(!is_sig_ign(signal_actions[_signum])) { _owner_thread->interrupted(true); } diff --git a/libc/unistd/getppid.c b/libc/unistd/getppid.c index f885a906e3..c452c62bd5 100644 --- a/libc/unistd/getppid.c +++ b/libc/unistd/getppid.c @@ -1,6 +1,7 @@ #include +#include pid_t getppid(void) { - return 0; + return OSV_PID; } diff --git a/runtime.cc b/runtime.cc index 20a19a430b..7871050473 100644 --- a/runtime.cc +++ b/runtime.cc @@ -60,6 +60,7 @@ #include #include #include +#include #define __LC_LAST 13 @@ -263,7 +264,7 @@ LFS64(posix_fallocate); int getpid() { - return 0; + return OSV_PID; } // WCTDEF(alnum), WCTDEF(alpha), WCTDEF(blank), WCTDEF(cntrl),