system-calls

What encoding used when invoke fopen or open?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 12:10:52
When we invoke system call in linux like ' open ' or stdio function like ' fopen ' we must provide a ' const char * filename '. My question is what is the encoding used here? It's utf-8 or ascii or iso8859-x? Does it depend on the system or environment setting? I know in MS Windows there is a _wopen which accept utf-16. It's a byte string, the interpretation is up to the particular filesystem. It depends on the system locale. Look at the output of the "locale" command. If the variables end in UTF-8, then your locale is UTF-8. Most modern linuxes will be using UTF-8. Although Andrew is correct

Why blocking system calls blocks entire procedure with user-level threads?

半腔热情 提交于 2019-11-30 09:42:27
I dont understand the following: User-level threads requires non-blocking systems call i.e., a multithreaded kernel. Otherwise, entire process will blocked in the kernel, even if there are runable threads left in the processes. How the kernel threads handle the blocking system calls? In the user-level threads when one thread is making a blocking system call (e.g. read) why cant other threads continue their work? In the user-level threads when one thread is making a blocking system call (e.g. read) why cant other threads continue their work? With user-level threads, as far as the OS and kernel

OsDev syscall/sysret and sysenter/sysexit instructions enabling

六月ゝ 毕业季﹏ 提交于 2019-11-30 08:54:08
问题 I am building an 32 bit OS in assembly. I have setup the IDT and I am handling program interruptus through int instruction. How can I enable the syscall and sysenter instructions and how do I handle them/return? Is true that syscall instruction isn't supported in 32 bit by Intel processors so I can't use it? Is true that sysret instruction isn't safe? Do somewhere exist a tutorial for that? EDIT : My main question is how to enable the syscall and sysenter instructions! (No duplication) 回答1:

Suppress console when calling “system” in C++

自古美人都是妖i 提交于 2019-11-30 08:16:28
问题 I'm using the system command in C++ to call some external program, and whenever I use it, a console window opens and closes after the command finishes. How can I avoid the opening of a console window? I would be happy if the solution could be platform-independent. I would also like for my program to wait until the command is finished. 回答1: It sounds like you're using windows. On Linux (and *nix in general), I'd replace the call to system with calls to fork and exec , respectively. On windows,

How does strace work?

隐身守侯 提交于 2019-11-30 06:27:16
It can trace all system calls used. But what differs a sys_call from a normal call?? As Matthew said, strace uses the ptrace(2) system call to work its magic. ptrace is used to implement debuggers and other tools which need to inspect what another program is doing. Essentially, strace will call ptrace and attach to a target process. Whenever the target process makes a system call, it will stop, and strace will be notified. strace will then inspect the registers and stack of the target process (also using ptrace) to determine what system call was being made (each call has a unique number,

Outlook “Run Script” rule not triggering VBA script for incoming messages

房东的猫 提交于 2019-11-30 06:06:51
问题 I am creating this new topic on the advice of another member. For additional history regarding how things arrived at this point see this question. I have this VBA script, that I know works if it gets triggered. If I use the TestLaunch subroutine with a message already in my inbox that meets the rule criteria (but, of course, isn't being kicked off by the rule) it activates the link I want it to activate flawlessly. If, when I create the rule I say to apply it to all existing messages in my

Adding a new system call in Linux kernel 3.3

梦想的初衷 提交于 2019-11-30 03:59:06
I am very new to this kernel thing. What I want to do is just add a new system call to the kernel. I was following this guideline: http://hekimian-williams.com/?p=20 . The problem is there used to syscall_table_32.S file under arch/x86/kernel, but I cannot find the file for x86 systems in kernel version 3.3. Do I still need to edit the file and append one more line for the newly added system call? Or do I need to do something else to let the kernel know about my new system call? Any help will be appreciated. Thank you. I think in kernel 3.3 its shifted here http://lxr.free-electrons.com/source

Why is printf before exevp not running?

折月煮酒 提交于 2019-11-29 23:20:47
问题 I get an output of "hi!". Why is this not also printing "something"? #include <stdio.h> #include <unistd.h> int main(int argc, char** argv) { char* program_name = "echo"; char* args[]= {program_name,"hi!",NULL}; printf("something"); execvp(program_name,args); return 0; } I know I'm not creating a child process first. If I take out the execvp line, it works as expected. Weird. (Note: "echo" refers to https://en.wikipedia.org/wiki/Echo_(command)) 回答1: The string is in the io buffer - so pull

Question about writing my own system call in FreeBSD

走远了吗. 提交于 2019-11-29 22:16:09
问题 OK, so I just finish reading the implementation of kill(2) of FreeBSD, and am trying to write my own "kill". This system call takes uid and signum and sends the signal to processes owned by uid, excluding the calling process. How can I pass uid to the system call? In kill(2), pid is in argument struct kill_args . Is there a structure that contains uid the way that struct kill_args contains pid ? If not, can I define a structure outside the kernel? 回答1: It's easy, but kind of an involved

How to hide command prompt window when using Exec in Golang?

半城伤御伤魂 提交于 2019-11-29 19:45:48
问题 say i have the following code, using syscall to hide command line window process := exec.Command(name, args...) process.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} err := process.Start() if err != nil { log.Print(err) } but when i compiled it and tried to run it in Windows, command line window showed up again what can i do to prevent command line window from appearing? PS i already know how to compile golang source into a Windows GUI executable using go build -ldflags -H=windowsgui ,