Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN Linux programming 8) dup(x) duplicates fd[x] in the first empty entry in the fd table. Run following program and explain the output. Assume f1

IN Linux programming

8) dup(x) duplicates fd[x] in the first empty entry in the fd table. Run following program and explain the output. Assume f1 has

hello my boy

x=open("f1", O_RDONLY, 00777);

int y;

y=dup(x);

printf("x:%d y:%d ", x, y);

char buf[50];

int k=read(x, buf, 5);

buf[k]=0;

printf("buf:%s ", buf);

k=read(y, buf, 5);

buf[k]=0;

printf("buf:%s ", buf);

9) (Standard output redirection) Explain the output of the following code.

x=open("f2", O_WRONLY|O_CREAT, 00777);

printf("x:%d ", x);

int y;

close(1);

y=dup(x);

printf("x:%d y:%d ", x, y);

write(1, "hi there", 8);

10) Change the shell such that it can handle standard output redirection.

$ cat f1 > f3

will redirect the output of "cat f1" to file f3.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions