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

Script passed as pipe, fix for locks, support for python #153

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fabio-brugnara
Copy link

This PR proposes a solution (at least in my experience), for a couple of questions appearing among the Issues.

  1. Remove the limitations of command line length limits and exposability by using pipes instead of command line to pass the script to the interpreter. A -P option is added to enable this.
  2. Remove occasional locks introduced by a race condition in the untraceable() function: the possibility that the CONT signal arrives before the process has actually entered the stopped state, being therefore discarded.
  3. Add support for python script.

A drawback of the "pipe" feature, is the fact that the script may lose the possibility to retrieve the original name by accessing $0. Often this can be worked around referring to the $_ environment variable, but not always. In exchange for this annoyance, the limit on the script size and the possibility of seeing the source in clear with ps or /proc/*/cmdline both disappear.

These modifications have been applied to the version found in Francisco Rosales' page and have been working reliably for years under linux.

src/shc.c Show resolved Hide resolved
src/shc.c Outdated
@@ -149,6 +150,9 @@ static int MMAP2_flag = 0;
static const char BUSYBOXON_line[] =
"#define BUSYBOXON %d /* Define as 1 to enable work with busybox */\n";
static int BUSYBOXON_flag = 0;
static const char PIPESCRIPT_line[] =
"#define PIPESCRIPT %d /* Define as 1 to submit script as a pipe */\n";
static int PIPESCRIPT_flag;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please initialize to 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but static variables are initialized to 0 anyway

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do, but if you feel it is necessary to modify something, you should have push access to my fork.
However, if you prefer to ask me to operate on it, no problem at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants