![]() |
|
|||
0001 /* 0002 * Copyright © 2018 Alexey Dobriyan <adobriyan@gmail.com> 0003 * 0004 * Permission to use, copy, modify, and distribute this software for any 0005 * purpose with or without fee is hereby granted, provided that the above 0006 * copyright notice and this permission notice appear in all copies. 0007 * 0008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 0009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 0010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 0011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 0012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 0013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 0014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 0015 */ 0016 // Test that /proc/self gives correct TGID. 0017 #undef NDEBUG 0018 #include <assert.h> 0019 #include <stdio.h> 0020 #include <unistd.h> 0021 0022 #include "proc.h" 0023 0024 int main(void) 0025 { 0026 char buf1[64], buf2[64]; 0027 pid_t pid; 0028 ssize_t rv; 0029 0030 pid = sys_getpid(); 0031 snprintf(buf1, sizeof(buf1), "%u", pid); 0032 0033 rv = readlink("/proc/self", buf2, sizeof(buf2)); 0034 assert(rv == strlen(buf1)); 0035 buf2[rv] = '\0'; 0036 assert(streq(buf1, buf2)); 0037 0038 return 0; 0039 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |