Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How long should the string used to store command feedback be? #1

Open
2 tasks
GoesM opened this issue Mar 11, 2024 · 1 comment
Open
2 tasks

How long should the string used to store command feedback be? #1

GoesM opened this issue Mar 11, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@GoesM
Copy link
Owner

GoesM commented Mar 11, 2024

Description

I met an issue when reading from the shell-command:

I have implemented the sharing of terminal command feedback results among multiple processes using shared memory.

size_t result_size_ = 1000000; // for string
char * result_ = (char *)mmap(
NULL, result_size_, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS,
-1, 0);

However, this shared memory is used to store strings. How large should I set it to be appropriate?

  • If it is too large, it will face the issue of wasting memory resources. If users execute multiple lightweight terminal commands simultaneously, it will incur considerable overhead.
  • If it is too small, when obtaining lengthy terminal feedback, it may lead to buffer-overflow problems.

TODO

  • which value is better?
  • is there any other ways to set it ? like in constructor(), provided by users ?
@GoesM GoesM added the help wanted Extra attention is needed label Mar 11, 2024
@jay-waves
Copy link

前排沙发😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants