Implemented getpid() and gettid()
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#include <magenta/object.h>
|
||||
#include <magenta/bootstrap.h>
|
||||
#include <magenta/errors.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <mio/fs.h>
|
||||
@@ -61,3 +64,23 @@ int close(int fd)
|
||||
__set_errno(0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pid_t getpid(void)
|
||||
{
|
||||
mx_info_task_t task_info;
|
||||
mx_status_t status = mx_object_get_info(
|
||||
mx_bootstrap_handle_get(MX_B_TASK_SELF),
|
||||
MX_INFO_TASK,
|
||||
&task_info, sizeof task_info);
|
||||
return status == MX_OK ? task_info.leader_id : (pid_t)-1;
|
||||
}
|
||||
|
||||
pid_t gettid(void)
|
||||
{
|
||||
mx_info_task_t task_info;
|
||||
mx_status_t status = mx_object_get_info(
|
||||
mx_bootstrap_handle_get(MX_B_TASK_SELF),
|
||||
MX_INFO_TASK,
|
||||
&task_info, sizeof task_info);
|
||||
return status == MX_OK ? task_info.id : (pid_t)-1;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,7 @@ extern int close(int fd);
|
||||
|
||||
extern off_t lseek(int fd, off_t off, int whence);
|
||||
|
||||
extern pid_t getpid(void);
|
||||
extern pid_t gettid(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user