return syscall(SYS_gettid);
}
+char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len) {
+ char *s = fgets(buf, buf_size, fp);
+ if(!s) return NULL;
+
+ char *t = s;
+ if(*t != '\0') {
+ // find the string end
+ while (*++t != '\0');
+
+ // trim trailing spaces/newlines/tabs
+ while (--t > s && *t == '\n')
+ *t = '\0';
+ }
+
+ if(len)
+ *len = t - s + 1;
+
+ return s;
+}
+