Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4273246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:41:13+00:00 2026-05-21T07:41:13+00:00

I am experiencing some pretty weird output from some c code. Granted I am

  • 0

I am experiencing some pretty weird output from some c code. Granted I am a newbie to c and Linux development, as my background is centered around .NET and C#.

In any case, I was supposed to write a FAT12 implementation and a command shell in c. My shell hangs whenever a child process tries to access shared memory. As a matter of fact nothing happens at all which is really weird. Can anyone help me debug the code?

Thanks,

This is the main loop that runs the shell:

while(strcmp(input, "EXIT") != 0 )
    {
        scanf("%s", input);
        input = String_ToFixedArray(input);

        array = StringArray_Create(input, " "); //split the input string into array.

        if( array->Items == NULL || array->Size == 0 )
        {
            input = "CONTINUE";
            continue;
        }

        if( strcmp(String_ToUpper(array->Items[0]), "PBS") == 0)
        {
            pid_t processId;

            if((processId = fork()) < 0 )
            {
                printf("%s", "Error executing command.");
            }

            //child process. Nothing happens???????
            if( processId == 0 )
            {
                ExecutePBS();
            }
        }
        else if( strcmp(String_ToUpper(array->Items[0]), "PFE") == 0 )
        {
            printf("Execute Print Fat Entries (PFE) Command\n");
        }
        else if( strcmp(String_ToUpper(array->Items[0]), "EXIT") == 0 )
        {
            printf("Exiting..");
            break;
        }
        else
        {
            input = "CONTINUE";
        }

    }

This is a “driver” function that will print the contents of the boot sector (PBS). The problem is that whenever this function executes, nothing happens!

void ExecutePBS(void)
{
    int shm_file_id;
    char* shm_file;
    char* shm_file_ptr;
    struct shmid_ds shm_file_buffer;

    if( (shm_file_id = shmget(SHM_FILE_NAME_KEY,SHM_FILE_NAME_SIZE, 0666)) < 0)
    {
        perror("Error locating shared memory segment.");
        exit(1);
    }

    if((shm_file = shmat(shm_file_id, NULL, 0)) == (char *) -1)
    {
        perror("Error attaching shared memory segment to process' scope.");
        exit(1);
    }

    if(shmctl(shm_file_id, IPC_STAT, &shm_file_buffer) == -1 )
    {
        perror("Error while attempting to control the shared memory segment used to store the floppy file name for IPC.");
        exit(1);
    }

    sprintf(shm_file_ptr, "%s", shm_file);

    if( shmdt(shm_file) == -1)
    {
        perror("Error releasing shared memory.");
        exit(1);
    }

    FILE* floppyImage = fopen(shm_file_ptr, "r+");

    if (floppyImage == NULL)
    {
        printf("Could not open the floppy drive or image.\n");
        exit(1);
    }

    BootSector* bootSector = BootSector_ReadBootSector(floppyImage);
    BootSector_ToString(bootSector);

    return;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:41:13+00:00Added an answer on May 21, 2026 at 7:41 am

    not really a big forker… but my understanding was that it returned = 0 for the child process != 0 for the parent… so you should have two lots of logic, one for each case… as it stands, after the client has called the method, it’s going to start going round the while loop as well, is that correct? also.. what do you mean by ‘nothing’ happens… have you tried putting printfs to increase visibility?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are experiencing some slowdowns on our web-app deployed on a Tomcat 5.5.17 running
Wanting to implement authentication by client certificates I am experiencing some issues. First some
I am working on an Orbited -powered website and I'm experiencing some annoying behavior
Our team has been experiencing a recurring problem with velocity templates. Upon rendering, some
I'm experiencing an issue on a test machine running Red Hat Linux (kernel version
I am experiencing some preverification error as decsribed in the object. I googled a
After experiencing numerous problems with a certain media player, it got me thinking is
I'm experiencing what I believe is a circular dependency issue with my PHP application.
I'm experiencing an issue with ActiveMQ and would like to trace/view all ActiveMQ activity.
I'm experiencing a strange issue where my Visual Studio 2005 C++ program crashes the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.