system-calls

Are system calls on Windows inherently slower than Linux?

隐身守侯 提交于 2019-12-12 08:06:43
问题 My understanding of system calls is that in Linux the system call mechanism ( int 0x80 or whatever) is documented and guaranteed to be stable across different kernel versions. Using this information, the system calls are implemented directly in the CRT library, so that when I call e.g. printf("a"); this involves a single function call to the CRT, where the system call is set up and activated. In theory this can be improved further by statically compiling the CRT (not common on Linux, but a

How to verify if the pointer is pointing to the process address table

大城市里の小女人 提交于 2019-12-12 04:55:47
问题 I am trying to write my own system call under Arch linux system , the following is the format of the system call: long getpeuid(pid_t pid, uid_t *uid) Which is used to get the euid of calling process's parent process. I know I have to verify three things first: check if the pointer is pointing to the user space. That can be done by access_ok() . check if the pointer is pointing to the calling process's address space. check if the calling process has the permission to write to the space the

Is it legal to pass a null program argument vector to execve()?

…衆ロ難τιáo~ 提交于 2019-12-12 04:55:28
问题 Consider following C code (x86_64) #include <unistd.h> int main() { execve("/bin/ls", 0, 0); } I compiled as gcc a.c and executed; I got a SIGABRT with error A NULL argv[0] was passed through an exec system call. Aborted Next running on gdb, at first I also got a SIGABRT , however I did second run and it worked! Starting program: /bin/ls [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Why? I tested for /bin/sh and found

How to call linux terminal code from R script

自古美人都是妖i 提交于 2019-12-12 04:15:16
问题 My question is: How can I call a Linux Terminal inside a R script ? I know it can be a silly question... my R code is here: download.file('https://some.dir, destfile = '/home/myfile.grb2',method='auto',quiet = FALSE, mode="wb", cacheOK = TRUE) after the download, I had to convert that file using a code from terminal... but I need this to be automatic. The converter code is this: source activate ncl_stable cd /home ncl_convert2nc myfile.grb2 Googling I saw that Linux Terminal uses C++ . I know

Build against newer linux headers than libc is built using

五迷三道 提交于 2019-12-12 03:39:24
问题 I want to write a program using the new SCHED_DEADLINE scheduling policy available since Linux 3.14. I start out with a simple program trying to use the sched_setattr function. #include <sched.h> int main(void) { // struct sched_attr attr; // attr.size = sizeof(struct sched_attr); // attr.sched_policy = SCHED_DEADLINE; sched_setattr(0, (void*)0, 0); return 0; } However when compiling I get the following error: $gcc dead.c dead.c: In function ‘main’: dead.c:8:2: warning: implicit declaration

Calling PFXExportCertStoreEx in Go does not return data

前提是你 提交于 2019-12-12 03:26:54
问题 I'm working in Go 1.6 on Windows and trying to export a certificate container to a PFX (the ultimate goal here is to access an exportable private key from the certificate store). I have opened a memory store and inserted a certificate into the store: var storedCertCtx *syscall.CertContext storeHandle, err := syscall.CertOpenStore(syscall.CERT_STORE_PROV_MEMORY, 0, 0, syscall.CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, 0) err = syscall.CertAddCertificateContextToStore(storeHandle, certenum,

What's the meaning “No data available(61)” during getxattr system call

两盒软妹~` 提交于 2019-12-12 01:59:36
问题 Daer all. I'm facing problem during trying Android CTS(4.4 R3). the whole of error logs are like below: 01-22 17:19:44.844 D/ (22802): isPermittedCapBitSet(): getxattr("/system/bin/run-as") call failed: return -1 (error: No data available (61)) 01-22 17:19:44.844 I/TestRunner(22802): failed: testRunAsHasCorrectCapabilities(android.permission.cts.FileSystemPermissionTest) 01-22 17:19:44.844 I/TestRunner(22802): ----- begin exception ----- 01-22 17:19:44.844 I/TestRunner(22802): 01-22 17:19:44

Linux c/c++ How to find PID from a ThreadID

不问归期 提交于 2019-12-11 20:42:39
问题 I'm currently writing a FUSE application that should implement process based access rights. I now stumble about the fact, that FUSE only provides the ThreadID, not the ProcessID. Now I need to find the PID (or Thread Group ID) for the given Thread ID of a different process. I noticed that the proc fs provides Thread based information (even a ls /proc does not show none PID TID's they can still be accessed through /proc/<TID>/) in this way I can ask /proc/<TID>/status about the Tgid, but as my

GNU Assembler (Mac OS X 64-bit): Illegal instruction: 4 [duplicate]

北慕城南 提交于 2019-12-11 20:39:26
问题 This question already has an answer here : basic assembly not working on Mac (x86_64+Lion)? (1 answer) Closed 5 months ago . I am new to GNU Assembler and I'm trying to execute this piece of code: .globl _main _main: movl $1, %eax movl $0, %ebx int $0x80 This programm should exit by the system call exit ( 1 ). Compiled it (no warnings): gcc test.s But running it gives me the error: Illegal instruction: 4 Thanks for help! 回答1: If you're compiling a 64-bit executable, then you should write

How to Override A C System Call?

旧城冷巷雨未停 提交于 2019-12-11 18:08:20
问题 So the problem is the following. The project needs to intercept all file IO operations, like open() and close() . I am trying to add printf() before calling the corresponding open() or close() . I am not supposed to rewrite the source code by changing open() or close() to myOpen() or myClose() for example. I have been trying to use LD_PRELOAD environment variable. But the indefinite loop problem came up. My problem is like this one. int open(char * path,int flags,int mode) { // print file