posix

Persistent execvp on pipe?

你离开我真会死。 提交于 2020-01-02 07:08:28
问题 I am working on an assignment for my Operating System class (Posix & C), building a mini-shell, and I don't know how to solve the following problem: My mini-shell has to accept two commands, for example ls | grep a . For that I create a pipe of size two and a child. The child closes all that it has to close and opens all that it has to open (standard/pipe's in & out). It then executes "ls," using execvp. I am sure this works well. After that, the parent shuts and opens inputs and outputs (I

Is it possible to send a signal to process that belongs to different user?

寵の児 提交于 2020-01-02 07:07:38
问题 I need to send a signal to different process for some real-time communication, however the process belongs to different user. For example PID user group 1234 foo foobar 4321 bar foobar I want process 1234 and 4321 to be able to send signals to each other? If I was using sockets or pipes I could set their mask to rw-rw-r-- and communication would work. However I need to do the communication using signals (ordinary or real time, not important). Is there a way to do it? 回答1: Quote from kill(2):

How does the POSIX 'tee' command work?

て烟熏妆下的殇ゞ 提交于 2020-01-02 06:26:13
问题 tee newOutputFile < existingInputFile > newOutputFile2 How exactly will tee take in the arguments? Would it be like this? Tee will first process newOutputFile < existingInputFile So the contents of existingInputFile will be written into newOutputFile newOutputFile > newOutputFile2 So the contents of newOutputFile will be written into newOutputFile 2 I am trying to write a shell that process this particular command. However, I am confused as to which order to pass in the arguments to tee . The

What does waitpid() do?

醉酒当歌 提交于 2020-01-02 03:25:22
问题 What is the use of waitpid() ? 回答1: It's used generally to wait until a specific process finishes (or otherwise changes state if you're using special flags), based on its process ID (otherwise known as a pid ). It can also be used to wait for any of a group of child processes, either one from a specific process group or any child of the current process. See here for the gory details. 回答2: It blocks the calling process until a nominated child process exits (or makes some other transition such

What are pthread cancelation points used for?

时光毁灭记忆、已成空白 提交于 2020-01-02 02:38:25
问题 There is discussion of pthread cancellation points (http://man7.org/linux/man-pages/man3/pthread_cancel.3.html) on several question. In some cases the respondents say that cancellation points should not be used unless the programmer knows what they are doing very well. My question---what are pthread cancellation points used for? [updated from comment] Does a cancellation point allow those specific API calls to be canceled? Why those and not others? Would anyone want to use them for anything

What corner cases must we consider when parsing $PATH on Linux?

妖精的绣舞 提交于 2020-01-02 02:38:20
问题 I'm working on a C application that has to walk $PATH to find full pathnames for binaries, and the only allowed dependency is glibc (i.e. no calling external programs like which). In the normal case, this just entails splitting getenv("PATH") by colons and checking each directory one by one, but I want to be sure I cover all of the possible corner cases. What gotchas should I look out for? In particular, are relative paths, paths starting with ~ meant to be expanded to $HOME, or paths

Interrupt (n)curses getch on incoming signal

╄→尐↘猪︶ㄣ 提交于 2020-01-02 00:54:11
问题 One of my programs uses ncurses for drawing a small tui. One of my goals is to make it rather portable to other curses implementations. This means that I want to catch a SIGWINCH issued by the terminal emulator on a resize operation myself and update my tui to adhere the changed geometry (and not depend on the resizing facilities of ncurses). Since POSIX (as far as I know) only allows access to sig_atomic_t variables within the signal handler, I set one to a different state. In the main loop,

How does one easily add posix support to PHP using yum?

吃可爱长大的小学妹 提交于 2020-01-02 00:14:36
问题 I am running CentOS 5.2 and using yum to manage packages. I have had little luck installing php-posix but know with almost 100% certitude that it is a real and available package...somewhere. Has anyone had luck installing it? FWIW, I am using the following: sudo yum install -y php-posix Update: I've realized that this may be an issue with my host (Slicehost) as I do in fact have cli, posix, and pcntl enabled for my PHP version (5.2.9) 回答1: You can try and see if it's in the testing repository

How does one easily add posix support to PHP using yum?

旧时模样 提交于 2020-01-02 00:14:08
问题 I am running CentOS 5.2 and using yum to manage packages. I have had little luck installing php-posix but know with almost 100% certitude that it is a real and available package...somewhere. Has anyone had luck installing it? FWIW, I am using the following: sudo yum install -y php-posix Update: I've realized that this may be an issue with my host (Slicehost) as I do in fact have cli, posix, and pcntl enabled for my PHP version (5.2.9) 回答1: You can try and see if it's in the testing repository

open(2) function hangs when trying to open serial port in MacOS

邮差的信 提交于 2020-01-02 00:12:22
问题 I've run into a problem where the open function never returns when I try to open a serial port. It doesn't happen all the time, and the problem disappears for a while if I unplug my USB to serial adapter and plug it back in. My code looks like this: fileDescriptor = open(bsdPath, O_RDWR | O_NOCTTY); where bsdPath is /dev/cu.KeySerial1 . I've tried adding the O_NONBLOCK option to the open command, but it still hangs. Of course I'd like to understand why this is happening. My belief is that