| ... | @@ -2959,6 +2959,10 @@ pub const Thread = struct { | ... | @@ -2959,6 +2959,10 @@ pub const Thread = struct { |
| 2959 | | 2959 | |
| 2960 | /// Returns the handle of this thread. | 2960 | /// Returns the handle of this thread. |
| 2961 | /// On Linux and POSIX, this is the same as Id. | 2961 | /// On Linux and POSIX, this is the same as Id. |
| | 2962 | /// On Linux, it is possible that the thread spawned with `spawnThread` |
| | 2963 | /// finishes executing entirely before the clone syscall completes. In this |
| | 2964 | /// case, this function will return 0 rather than the no-longer-existing thread's |
| | 2965 | /// pid. |
| 2962 | pub fn handle(self: Thread) Handle { | 2966 | pub fn handle(self: Thread) Handle { |
| 2963 | return self.data.handle; | 2967 | return self.data.handle; |
| 2964 | } | 2968 | } |
| ... | @@ -2977,7 +2981,7 @@ pub const Thread = struct { | ... | @@ -2977,7 +2981,7 @@ pub const Thread = struct { |
| 2977 | } else switch (builtin.os) { | 2981 | } else switch (builtin.os) { |
| 2978 | builtin.Os.linux => { | 2982 | builtin.Os.linux => { |
| 2979 | while (true) { | 2983 | while (true) { |
| 2980 | const pid_value = @atomicLoad(i32, &self.data.handle, builtin.AtomicOrder.SeqCst); | 2984 | const pid_value = @atomicLoad(i32, &self.data.handle, .SeqCst); |
| 2981 | if (pid_value == 0) break; | 2985 | if (pid_value == 0) break; |
| 2982 | const rc = linux.futex_wait(&self.data.handle, linux.FUTEX_WAIT, pid_value, null); | 2986 | const rc = linux.futex_wait(&self.data.handle, linux.FUTEX_WAIT, pid_value, null); |
| 2983 | switch (linux.getErrno(rc)) { | 2987 | switch (linux.getErrno(rc)) { |