| Index: mojo/edk/platform/platform_handle.cc
|
| diff --git a/mojo/edk/platform/platform_handle.cc b/mojo/edk/platform/platform_handle.cc
|
| index 8a7c7be1b70d16eb3745e129f50932969dc49f3b..c65600e424237f6833226f2286a478e1ba3a630d 100644
|
| --- a/mojo/edk/platform/platform_handle.cc
|
| +++ b/mojo/edk/platform/platform_handle.cc
|
| @@ -8,6 +8,8 @@
|
| #include <errno.h>
|
| #include <unistd.h>
|
|
|
| +#include "mojo/edk/platform/scoped_platform_handle.h"
|
| +
|
| namespace mojo {
|
| namespace platform {
|
|
|
| @@ -26,5 +28,15 @@ void PlatformHandle::CloseIfNecessary() {
|
| fd = -1;
|
| }
|
|
|
| +ScopedPlatformHandle PlatformHandle::Duplicate() const {
|
| + // This is slightly redundant, but it's good to be safe (and avoid the system
|
| + // call and resulting EBADF).
|
| + if (!is_valid())
|
| + return ScopedPlatformHandle();
|
| + // Note that |dup()| returns -1 on error (which is exactly the value we use
|
| + // for invalid |PlatformHandle| FDs).
|
| + return ScopedPlatformHandle(PlatformHandle(dup(fd)));
|
| +}
|
| +
|
| } // namespace embedder
|
| } // namespace mojo
|
|
|