summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-11-18 05:06:35 +0000
committersabetts <sabetts>2003-11-18 05:06:35 +0000
commitcf7ad617d4ce46c6bac6ac28e5323ab53e3ef17b (patch)
tree93a685a928d7ac7ae2960bf7441415f597ff6090 /src/main.c
parent5c658d8011fd459418a94e3524df0a72e08cd11b (diff)
downloadratpoison-cf7ad617d4ce46c6bac6ac28e5323ab53e3ef17b.zip
* contrib/rpshowall.sh: store ratpoison binary location in
RATPOISON env var. * src/ratpoison.h (FD_CLOEXEC): new define (set_close_on_exec): new prototype * src/main.c (ratpoison_longopts): add "interactive" option. (ratpoison_opts): likewise (print_help): print a help line for interactive option. (set_close_on_exec): new function (read_startup_files): call set_close_on_exec on file pointer (main): parse interactive command line option and pass it to send_command. * src/events.c (execute_remote_command): pass the interactive bit to command. * src/communications.c (send_command): send an interactive bit at the beginning of the message. Take an interactive argument. All callers updated. Prototype updated. * src/actions.c (cmd_source): call set_close_on_exec on file pointer.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index e44ee62..e252d75 100644
--- a/src/main.c
+++ b/src/main.c
@@ -48,14 +48,15 @@ static void init_screen (rp_screen *s, int screen_num);
/* Command line options */
static struct option ratpoison_longopts[] =
- { {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"command", required_argument, 0, 'c'},
- {"display", required_argument, 0, 'd'},
- {"screen", required_argument, 0, 's'},
- {0, 0, 0, 0} };
+ { {"help", no_argument, 0, 'h'},
+ {"interactive", no_argument, 0, 'i'},
+ {"version", no_argument, 0, 'v'},
+ {"command", required_argument, 0, 'c'},
+ {"display", required_argument, 0, 'd'},
+ {"screen", required_argument, 0, 's'},
+ {0, 0, 0, 0} };
-static char ratpoison_opts[] = "hvc:d:s:";
+static char ratpoison_opts[] = "hvic:d:s:";
void
fatal (const char *msg)
@@ -289,7 +290,8 @@ print_help ()
printf ("-v, --version Display the version\n");
printf ("-d, --display <dpy> Set the X display to use\n");
printf ("-s, --screen <num> Only use the specified screen\n");
- printf ("-c, --command <cmd> Send ratpoison a colon-command\n\n");
+ printf ("-c, --command <cmd> Send ratpoison a colon-command\n");
+ printf ("-i, --interactive Execute commands in interactive mode\n\n");
printf ("Report bugs to ratpoison-devel@lists.sourceforge.net\n\n");
@@ -297,6 +299,15 @@ print_help ()
}
void
+set_close_on_exec (FILE *fd)
+{
+ int fnum = fileno (fd);
+ int flags = fcntl (fnum, F_GETFD);
+ if (flags >= 0)
+ fcntl (fnum, F_SETFD, flags | FD_CLOEXEC);
+}
+
+void
read_rc_file (FILE *file)
{
size_t n = 256;
@@ -384,6 +395,7 @@ read_startup_files ()
if (fileptr)
{
+ set_close_on_exec(fileptr);
read_rc_file (fileptr);
fclose (fileptr);
}
@@ -484,6 +496,7 @@ main (int argc, char *argv[])
int screen_arg = 0;
int screen_num = 0;
char *display = NULL;
+ unsigned char interactive = 0;
myargv = argv;
@@ -524,6 +537,9 @@ main (int argc, char *argv[])
screen_arg = 1;
screen_num = strtol (optarg, NULL, 10);
break;
+ case 'i':
+ interactive = 1;
+ break;
default:
exit (EXIT_FAILURE);
@@ -549,9 +565,9 @@ main (int argc, char *argv[])
for (i=0; i<cmd_count; i++)
{
if (screen_arg)
- send_command (command[i], screen_num);
+ send_command (interactive, command[i], screen_num);
else
- send_command (command[i], -1);
+ send_command (interactive, command[i], -1);
free (command[i]);
}