ExamVeda
Login
Home
61
What is the output of second program if we run the demo1 first and after that we run demo2 in the different terminal?
/*This is demo1.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<string.h>
 
int main()
{
    int shm_id;
    char *addr;
    struct shmid_ds ds;
    shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
    if(shm_id == -1){
        perror("shmget");
    }
    addr = (char*)shmat(shm_id,NULL,SHM_RND);
    if(addr == (char *)-1){
        perror("shmat");
    }
    strcpy(addr,"Example");
    if (shmdt(addr) != 0){
        perror("shmdt");
    }
    sleep(10);      
    if( shmctl(shm_id,IPC_RMID,0) == -1){
        perror("shmctl");
    }
    return 0;
}
/*This is demo2.c*/
#include<stdio.h>
#include<sys/ipc.h>
#include<sys/shm.h>
 
int main()
{
    int shm_id;
    char *addr;
    struct shmid_ds ds;
    shm_id = shmget((key_t)1234,10,0666|IPC_CREAT);
    if(shm_id == -1){
        perror("shmget");
    }
    addr = (char*)shmat(shm_id,NULL,SHM_RND);
    if(addr == (char *)-1){
        perror("shmat");
    }
    printf("%s\n",addr);
    if (shmdt(addr) != 0){
        perror("shmdt");
    }
    return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
62
What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
 
int main()
{
    int *ptr;
    ptr = (int *)calloc(1,sizeof(int));
    if (ptr != 0)
        printf("%d\n",*ptr);
    return 0;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
63
If any sed command does not specify any address then the command is applied to
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
64
Which command will you use to see the available routes?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
65
Which one shows the name of the operating system?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
66
Which option of the kill command sends the given signal name to the specified process?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
67
Proc filesystem provides the information about
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
68
The command "cd /proc/10/cwd" provides the
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
69
What is the output of this program?
#!/bin/sh
test_function1() {
    a=5
    echo "This is the first function"
    test_function2
}
test_function2() {
    echo "This is the second function" 
    test_function3
}
test_function3() {
    echo "This is the third function"
}
test_function1
exit 0
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
70
"ps" command uses the file . . . . . . . . to provide the information.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board