Process issue continuation

Source: Internet
Author: User
Process issue continuation-Linux general technology-Linux programming and kernel information. The following is a detailed description. I improved my program, but there was a new problem. my program is as follows:
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Define KEY 25

Void h_exit (int status );
Int main ()
{
Int shmid;
Char * shmptr;
Int * status;
Pid_t pid;
If (shmid = shmget (KEY, 1000, IPC_CREAT) <0)
{
Printf ("Here is the server: error, get share memeroy failed! \ N ");
Exit (1 );
}
If (shmptr = (char *) shmat (shmid, 0, 0) = (void *)-1)
{
Printf ("Here is the server: error, to make the shmat \ n ");
Exit (1 );
}

Printf ("Here is the server: shmid: % d shmptr: % d", shmid, shmptr );
Fgets (shmptr, 10, stdin );
If (pid = fork () <0)
{
Printf ("Here is the server: creat child process wrong ");
Exit (1 );
}
If (pid = 0)
{
If (execl ("./receiver", NULL) <0)
{
Printf ("Here is the child: wrong change to author ER ");
Exit (0 );
}
Printf ("I have got into the receiver \ n ");
}
Else
{
If (wait (status) <0)
{
Printf ("Here is the parent: wrong in wait \ n ");
Exit (0 );
}
}
H_exit (* status );
Return 0;
}
Void h_exit (int status)
{
If (WIFEXITED (status ))
Printf ("normal termination, exit status = % d. \ n", WEXITSTATUS (status ));
}
Run-time display:
Here is the parent: wrong in wait
It can be seen that wait has an error. Generally, there should be no subprograms, but I have clearly generated subfunctions. I don't know where the error is?
Could you give me some advice ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.