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 9054363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:40:19+00:00 2026-06-16T13:40:19+00:00

I have a textarea in my webpage in which the user is to paste

  • 0

I have a textarea in my webpage in which the user is to paste a c program. At the server side, I save this code in a file appropriately. I use the shell_exec() function to call gcc to execute the c program. This works fine. And so does the execution part.

But what if the user (un)intentionally gives an infinite loop? When I use the function –

     shell_exec("./a.out")

the program goes into an infinite loop. How do I break out of such a loop from the php script itself? Is there a way?

  • 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-06-16T13:40:21+00:00Added an answer on June 16, 2026 at 1:40 pm

    Use ulimit to limit the CPU usage? Note that this is per process, so if the user “forks” continually the process, you may be in trouble.

    Another method would be to have a wrapper process that monitors and kills all it’s child processes, and let that start the a.out. It depends on whether you can trust your “clients” or not (e.g. are they your good friends, or is this a school project or a public website) – your paranoia level should increase by threat level.

    If you want more refined security, run the process via ssh in a virtual machine. Then just kill the virtual machine after X seconds, and start a fresh one from a saved snapshot. (You could have a pool of VM’s ready to run, so the user don’t have to wait for the VM to load)

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

Sidebar

Related Questions

I have a textarea on my page. It has this draggable corner which lets
I have a textarea in which the user enters the following data: Paul:Nine, Rome
I have a textarea field on my webpage. I am accepting the user input,
I have a textarea on my webpage which will get its value parsed and
I have a webpage that the user inputs data into a textarea and then
I have textarea in my site(link shortening site) i want to user enter some
I have a textarea with this content: <textarea id=text> Hello! Who am I? This
I have a section on a webpage that is generated like this. <table> <c:forEach
I have a <textarea> for user input, and, as they are invited to do,
so I have my PHP file (it all works fine the php side of

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.