Age | Commit message (Collapse) | Author | Files |
|
|
|
|
|
The "environ" statement is now a compound statement. It can contain five
kinds of substatements: "clear" to clear the environment, "keep" to retain
certain variables while clearing the environment, "set" to set a variable,
"unset" to unset a variable or variables, and "eval" to evaluate a variable
reference for side effects.
Both "keep" and "unset" can take globbing pattern as their argument,
in which case they affect all variables matching that pattern.
The value part in the "set" statement is subject to variable expansion,
e.g.
set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man"
The "environ" block can appear in global context as well. In this case it
applies to all watchers.
The support for the old one-line "environ" statement is retained for
backward compatibility.
* grecs: Upgrade.
* src/Makefile.am: Add new files.
* src/envop.c: New file (fromGNU pies).
* src/envop.h: Likewise.
* src/wildmatch.c: Likewise.
* src/config.c: Add support for block "environ" statement, both global
and watcher-scope.
Turn off concatenation of adjacent string literals.
* src/direvent.h: Include envop.h
(prog_handler): Remove env. New field envop.
(prog_handler_envrealloc): Remove.
(direvent_envop): New global.
* src/environ.c: Remove.
* src/progman.c (parse_legacy_env): New function.
(runcmd): Rewrite.
(prog_handler_envrealloc): Remove.
* tests/Makefile.am: Add new testcases.
* tests/testsuite.at: Likewise.
* tests/env00.at: New file.
* tests/env01.at: New file.
* tests/env02.at: New file.
* tests/env03.at: New file.
* tests/env04.at: New file.
* tests/env05.at: New file.
* tests/env06.at: New file.
* tests/envdump.c: New options: -A and -D.
* tests/envleg00.at: New file (renamed from env00.at).
* tests/envleg01.at: New file (renamed from env01.at).
* tests/envleg02.at: New file (renamed from env02.at).
* tests/envleg03.at: New file (renamed from env03.at).
* tests/shell.at: Use backslash continuation instead of
relying on implicit concatenation of adjacent string literals.
|
|
* src/direvent.c (trans_stat, flags_format, ev_format): New functions.
(ev_log): Rewrite.
* src/direvent.h (ev_format): New prototype.
(ev_log): Change prototype.
* src/ev_inotify.c (process_event): Use new logging functions.
* src/ev_kqueue.c: Likewise.
* src/progman.c (runcmd): Use ev_format to format values for genev_name
and sysev_name.
|
|
* configure.ac: Select interface to use for bulk closing of the open
file descriptors.
* src/Makefile.am: Add closefds.c
* src/closefds.c: New file.
* src/direvent.h (close_fds): New proto.
* src/progman.c: Use new close_fds.
|
|
* src/direvent.h (watchpoint): Remove the written field.
[IFACE_KQUEUE] New field file_changed.
[IFACE_INOTIFY] New field files_changed.
* src/ev_inotify.c (file_changed): New function.
(process_event): Use file_changed to verify file status.
* src/ev_kqueue.c (sysev_add_watch,process_event): written renamed to
file_changed.
* src/watcher.c (watchpoint_unref) [IFACE_INOTIFY]: Deallocate
files_changed.
|
|
* src/direvent.c (nomem_abend): New function.
(emalloc,ecalloc,erealloc): Use nomem_abend on out of memory
error.
* src/direvent.h (nomem_abend): New proto.
* src/ev_inotify.c (process_event): The "changed" generic event
includes creation of the file.
Add missing gettext markers.
Don't process events generated for the watchpoint directory itself.
* src/ev_kqueue.c: Add missing gettext markers.
* src/progman.c: Revamp debug messages.
* src/watcher.c (watchpoint_filemask): New function.
(watchpoint_install): Call nomem_abend on out of memory
error.
(watchpoint_suspend): Stop the program if unable to install sentinel.
(directory_sentinel_handler_run,watch_subdirs): Use watchpoint_filemask.
|
|
* src/direvent.h (watchpoint) <written>: Move out of preprocessor
conditional.
* src/ev_inotify.c (genev_xlat): GENEV_WRITE maps to GENEV_WRITE.
(sysev_add_watch): If GENEV_CHANGE is requested, raise
IN_MODIFY and IN_CLOSE_WRITE.
(process_event): Translate system events to generic event mask
prior to distributing the event to handlers.
* src/progman.c (close_fds): One more fix. See also cba6578a56
* tests/change.at: New testcase.
* tests/Makefile.am: Add change.at
* tests/testsuite.at: Include change.at
* tests/createrec2.at: Reorder options to genfile.
* tests/genfile.c: Accept multiple -s and -t options.
|
|
* src/config.c (cb_watcher): Use evtfill.
* src/direvent.c (trans_fullmask): New function.
(genev_init): Remove. All references changed.
* src/direvent.h (GENEV_CHANGE): New generic event.
(handler_matches_event): Remove macro.
(defevt,event_mask_init,evtsetall,genev_xlat): Remove declarations.
(evtempty,evtfill)
(evtrans_sys_to_gen,evtrans_gen_to_sys)
(trans_fullmask): New protos.
(watchpoint_run_handlers): Change signature.
* src/ev_kqueue.c (genev_xlat): Change GENEV_WRITE translation.
(sysev_add_watch): Change computation of sysmask.
(process_event): Translate system event flags to generici event mask
prior to distributing the event to handlers.
Don't call user handlers for directories.
* src/event.c (getevt): Rewrite.
(defevt,event_mask_init): Remove.
(evtempty,evtfill,evtand,evtrans_sys_to_gen)
(evtrans_gen_to_sys): New functions.
(genev_transtab): Declare the "change" event.
* src/handler.c (watchpoint_run_handlers): Take event_mask as argument.
Change logic accordingly.
* src/watcher.c (deliver_ev_create): Use evtand and filpatlist_match
explicitly, instead of the removed handler_matches_event.
|
|
* src/direvent.h (watcher): Remove watch_written.
* src/ev_kqueue.c (sysev_add_watch,process_event): Update accordingly.
|
|
* src/direvent.h (watchpoint): Remove file_mode.
* src/ev_kqueue.c (sysev_add_watch): Actually register new event to
minimize the race condition window.
(check_created): Check for error if readdir returns NULL.
(process_event): Check for new files and directories after running
event handlers.
* src/progman.c (close_fds): Bugfix. Start from the highest possible fd.
(open_redirector): Fix loop condition.
* src/watcher.c (watch_subdirs): Check for error if readdir returns NULL.
* tests/listname: New auxiliary script.
* tests/Makefile.am: Distribute listname.
* tests/createrec.at: Rewrite test. Use the listname script to monitor
and govern it.
* tests/createrec3.at: Likewise.
|
|
* src/direvent.h (event_handler_fn): Additional argument: notify.
(watchpoint) [USE_IFACE == IFACE_KQUEUE]: New members: watch_written,
written.
* src/ev_kqueue.c (sysev_transtab): Define more system events (if
defined).
(genev_xlat): Depending on whether NOTE_CLOSE_WRITE is defined,
change GENEV_WRITE translation.
(sysev_add_watch) [NOTE_CLOSE_WRITE]: Initialize written and watch_written.
Update sysmask.
(process_event): Special handling for watch_written!=0
* src/handler.c (watchpoint_run_handlers): Pass notify (1) to hp->run.
* src/progman.c (prog_handler_run): New argument: notify. Do nothing
if it's 0.
* src/watcher.c (sentinel_handler_run): New argument: notify. Pass it
deliver_ev_create.
(directory_sentinel_handler_run): New argument: notify. Pass it
to watch_subdirs.
Call watchpoint_attach_directory_sentinel if using IFACE_KQUEUE.
(deliver_ev_create): Pass notify to hp->run.
* tests/createrec3.at: New test.
* tests/genfile.c: New program.
* tests/Makefile.am: Add createrec3.at
(noinst_PROGRAMS): Add genfile.
* tests/createrec2.at: Use genfile with 1 second delay.
* tests/sent.at: Update expected output.
* tests/testsuite.at: Add genfile.
|
|
* src/config.c (eventconf_flush): Attach directory sentinel
when recursive whatching is enabled or when using IFACE_KQUEUE
* src/direvent.h (handler) <notify_always>: New member.
(recent_head): New type.
(watchpoint) <rhead>: New member.
(check_new_watcher): Remove.
(watchpoint_attach_directory_sentinel): New proto.
(deliver_ev_create): Change signature.
(watchpoint_recent_init)
(watchpoint_recent_deinit)
(watchpoint_recent_lookup)
(watchpoint_recent_cleanup): New protos.
(handler_list_append_cow)
(handler_list_remove_cow): New protos.
* src/ev_inotify.c (process_event): When a IN_CREATE is received,
first check if the created file is in the recent file list (rhead).
If so, don't deliver the event. This avoids spurious create events.
* src/ev_kqueue.c (sysev_filemask): Always return S_IFMT.
(check_created): Deliver the create event. Remove call to
subwatcher_create. The create event will trigger creation of new
watchpoints.
* src/handler.c (handler_list_dup): New function.
(handler_list_append_cow)
(handler_list_remove_cow): New copy-on-write interfaces.
* src/progman.c (process_timeouts): Initialize alarm_time with the
return from watchpoint_recent_cleanup. Initialize the notify_always
member of the struct handler.
* src/watcher.c (watchpoint_unref): De-initialize the recent object
list.
(watchpoint_destroy): Likewise.
(watchpoint_recent_init)
(watchpoint_recent_deinit)
(watchpoint_recent_lookup)
(watchpoint_recent_cleanup): New functions. Maintain the list of
recent objects.
(watchpoint_install_sentinel): Set notify_always.
(directory_sentinel_handler_run)
(watchpoint_attach_directory_sentinel): New functions.
(watchpoint_init): Don't enforce create event if recursive watching is
enabled.
(subwatcher_create,check_new_watcher): Remove.
(deliver_ev_create): New argument: notify.
(watch_subdirs): Rewrite.
* tests/createrec2.at: Re-insert delays between directory and file
creation.
|
|
This also makes createrec2.sh pass on BSD systems
* src/direvent.h: Remove GENEV_OOB
* src/event.c (genev_transtab): Likewise.
* src/ev_kqueue.c (check_created): Set a subwatcher only if
parent watcher depth is not 0.
* src/watcher.c (deliver_ev_create) Revert previous commit.
(watch_subdirs): Clear S_IFDIR bit if parent depth is 0.
|
|
Deliver such events to each handler that receives CREATE and WRITE
events. This makes sure all handler have a chance to notice creation
of a file within the time that expires between creation of a directory
and creation of a watchpoint for it. Introduce new marker (flag) for
such out of band data.
Make sure out of band CREATE notifications are sent to the deepest
created watchpoint, in case the recursion depth is limited.
* src/direvent.h (GENEV_OOB): New macro for out of band events.
* src/event.c (genev_transtab): Add an entry for GENEV_OOB.
* src/watcher.c (deliver_ev_create): Deliver out of band CREATE
event. Receipients are all handlers that requested CREATE or WRITE
events.
(check_new_watcher): Fix misleading comment.
(watch_subdirs): Make sure out of band CREATE notifications are sent
if the watchpoint has zero depth (last directory in a depth-limited
recusive watchpoint chain).
* tests/createrec2.at: Remove sleeps between creation of a directory
and creation of a file in it.
|
|
|
|
* grecs: Pull new version.
* src/hashtab.c: Remove.
* po/POTFILES.in: Remove src/hashtab.c
* src/Makefile.am (direvent_SOURCES): Remove hashtab.c
* src/config.c (grecs_parser_options): Set GRECS_OPTION_QUOTED_STRING_CONCAT.
* src/direvent.h: Remove hashtab prototypes.
* src/event.c: Use grecs_symtab.
* src/watcher.c: Likewise.
|
|
* src/direvent.c (main): Call watchpoint_gc in the main loop.
* src/direvent.h (watchpoint) <isdir>: New member.
(deliver_ev_create,subwatcher_create): Change signature.
* src/ev_kqueue.c (sysev_add_watch): Always monitor NOTE_DELETE.
(process_event): Special handling for file deletion.
* src/handler.c (handler_list_remove): Return the number of elements
remaining in the list.
* src/hashtab.c (hashtab_remove): Ignore unexisting entries
* src/progman.c (close_fds): Determine the highest used fd by
dup'ing standard input.
* src/watcher.c (watchpoint_install): Always increase refcnt.
(watchpoint_gc_list): New variable.
(watchpoint_gc): Iterate over watchpoint_gc_list deleting
elements from it.
(watchpoint_suspend): Install sentinels only for top-level
watchpoints that were removed.
(sentinel_handler_run): Deliver the create event.
(watchpoint_install_sentinel): Monitor generic create event.
(convert_watcher): Remove.
(subwatcher_create): Remove the isdir parameter.
(watch_subdirs): Exit early if the watchpoint is not a
directory.
(deliver_ev_create): Change signature. Take both directory
and file name as arguments. All uses changes.
* tests/conv.at: Clear expected stderr.
* tests/sent.at: Fix race condition.
|
|
* src/direvent.h (filpatlist_is_empty): New proto.
* src/fnpat.c (filpatlist_is_empty): New function.
* src/watcher.c (convert_watcher): Fix error handling.
(watchpoint_init): Remove spurious notice.
* tests/conv.at: New test.
* tests/sent.at: New test.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.
|
|
Instead of accomodating two types of functionality, the new struct handler
has a pointer to the function that is responsible for handling the event,
and a pointer to data for that function (closure). Additionally, a
pointer to deallocator function is also provided.
Existing functionality is reimplemented using this new struct. New
types of handlers can easily be added.
* src/config.c (eventconf)<ev_mask,fpat,prog_handler>: New members
<handler>: Remove.
All uses changed.
* src/direvent.h (filpatlist_t)
(event_handler_fn, handler_free_fn): New data types.
(handler): Remove union and type. Add two pointer to functions
that are to implement the functionality (run and free) and a pointer
to data for them.
(prog_handler): New struct.
(prog_handler_alloc,prog_handler_free)
(prog_handler_envrealloc)
(watchpoint_run_handlers): New protos.
(run_handler,filename_pattern_free)
(filename_pattern_match): Remove
(filpatlist_add, filpatlist_add_exact)
(filpatlist_destroy, filpatlist_match): New protos.
* src/ev_inotify.c (process_event): Use watchpoint_run_handlers
* src/ev_kqueue.c: Likewise.
* src/fnpat.c: Major rewrite.
* src/handler.c (handler_copy)
(handler_envrealloc,handler_add_pattern)
(handler_add_exact_filename): Remove
(handler_alloc): Change arguments.
(watchpoint_run_handlers): New function.
* src/progman.c (prog_handler_alloc)
(prog_handler_envrealloc): New functions.
* src/watcher.c: Reimplement sentinel watchers.
|
|
|
|
Sentinel handlers wait for a creation of a directory. When
the target directory is created, the sentinel handler installs
the actual handler for that directory and destroys itself. Thus,
basically sentinel handlers provide a way to defer setting a
watchpoint on a directory until it is created.
* src/handler.c: New source.
* src/Makefile.am (direvent_SOURCES): Add handler.c
* src/config.c: Move handler-specific stuff to handler.c
* src/direvent.h: Rename direvent_handler_ to handler_
(handler_free, handler_copy)
(handler_envrealloc)
(dirwatcher_init,dirwatcher_gc): New protos.
(dirwatcher_install_ptr)
(dirwatcher_install_sentinel): New protos.
* src/ev_inotify.c (process_event): Special handling for
IN_IGNORED.
(sysev_select): Ignore signo==0.
* src/hashtab.c (hashtab_remove): Add missing return statement.
(hashtab_foreach): Break out of look instead of returning from
it.
* src/progman.c (run_sentinel): Implement.
* src/watcher.c (+dirwatcher_install_ptr): New function.
(dirwatcher_gc): New function.
|
|
* src/direvent.h (pattern_type): New enum, instead of
PAT_* defines.
(filename_pattern): use enum pattern_type.
(handler_type): New enum.
(handler): Can be of two types: HANDLER_EXTERN, which handles
external programs and is equivalent to the prior content of
the structure, and HANDLER_SENTINEL, which is planned to be
a built-in handler for configuring watchpoints for newly created
directories. All uses changed.
(dirwatcher) <refcnt>: Change type to size_t.
(handler_alloc,handler_add_pattern)
(handler_add_exact_filename): New protos.
* src/hashtab.c: Provisions for safe adding and removing
from the hashtable when iterating over it.
(hashtab) <flags>: Removed.
<itr_level, list_new, list_del>: New members.
(hashtab_remove): When iterating, place pointer to the removed
entry in list_del instead of actually removing it.
(hashtab_lookup_or_install): When iterating, add a pointer to
the newly created entry to the list_new list, instead of adding
it immediately.
(hashtab_foreach): Flush list_del and list_new at the end of
the topmost iteration.
* src/config.c (handler_alloc): Rename to handler_copy
(handler_alloc): New function.
(handler_free): Two types of handlers.
(handler_add_pattern)
(handler_add_exact_filename): New functions.
(file_name_pattern): Takes struct handler * as its
first argument.
(cb_file_pattern): Change accordingly.
* src/fnpat.c (filename_pattern_free): Handle PAT_EXACT.
(filename_pattern_match): Likewise.
* src/progman.c (run_handler): Two types of handlers.
* src/watcher.c (dirwatcher_install): Restore missing gettext
marker.
Allocate handler_list.
(dirwatcher_init): Convert non-directory watchpoints to directory
ones.
|
|
Don't create duplicates of handler structs for each pathname
watched. Instead keep a count of references to each handler
and handler list and deallocate them when the count falls to
zero.
* src/config.c (direvent_handler_list): New struct.
(direvent_handler_first,direvent_handler_next)
(direvent_handler_current)
(direvent_handler_list_create)
(direvent_handler_list_copy)
(direvent_handler_list_unref)
(direvent_handler_list_append): New functions.
(eventconf_flush): Create a single copy of watcher.
* src/direvent.c (main): Call shutdown_watchers before terminating.
* src/direvent.h (handler) <next>: Remove.
<refcnt>: New member.
<prog>: Remove const qualifier.
(direvent_handler_list_t)
(direvent_handler_iterator_t): New data types.
(dirwatcher): Remove handler_tail. Change type of
handler_list to direvent_handler_list_t.
(shutdown_watchers)
(direvent_handler_first,direvent_handler_next)
(direvent_handler_current)
(direvent_handler_list_create)
(direvent_handler_list_copy)
(direvent_handler_list_unref)
(direvent_handler_list_append): New protos.
(for_each_handler): New define.
* src/watcher.c (dirwatcher_unref): Call direvent_handler_list_unref.
(all functions): Use handler iterators where necessary
(shutdown_watchers): New function.
* src/ev_inotify.c: Use handler iterators.
* src/ev_kqueue.c: Likewise.
|
|
* NEWS: Update.
* configure.ac: Update.
* src/watcher.c (setwatcher): Fix conditional.
* src/direvent.h (dirwatcher_pattern_match): Add missing prototype.
|
|
During the lifetime of a watcher, its descriptor can change, so
it cannot be reliably used to identify the watcher outside of
the ev_*.c module. E.g. for kqueue interface, descriptors change
after compacting the event table, which happens when a watcher is
closed and removed.
Finding the watcher for the given event is now the responsibility
of the event module.
* src/direvent.h (dirwatcher_ref)
(dirwatcher_unref): New protos.
(dirwatcher_lookup_wd): Remove.
* src/watcher.c (dirwatcher_ref): New function.
(dirwatcher_register, dirwatcher_lookup_wd)
(dirwatcher_remove_wd): Remove. All uses updated.
(setwatcher): Indicate successful initialization for
the caller.
(setup_watchers): Check success flag.
* src/ev_inotify.c (dwreg, dwunreg)
(dwget): New functions to keep track of the registered
watchers and their descriptors.
(sysev_add_watch): Register watcher.
(sysev_rm_watch): Deregister it.
* src/ev_kqueue.c (check_created): Skip directory entries
that don't match pattern.
|
|
* src/Makefile.am (AM_CPPFLAGS): Define SYSCONFDIR.
* src/direvent.c (mkfilename): Don't append trailing /
if filename is empty.
* src/direvent.h (hashtab_count_entries): Remove.
* src/ev_inotify.c (process_event): Translate IN_IGNORED to IN_DELETE.
Remove the watcher only after all handlers have been invoked.
* src/hashtab.c (hashtab) <elcount>: New member. Keep the number
of actually used elements.
(hashtab_remove, hashtab_lookup_or_install)
(hashtab_create,hashtab_clear): Keep track of the number of
actually used elements.
(hashtab_count_entries): Remove duplicate function.
(hashtab_count): Return elcount without recomputing.
* src/watcher.c (texttab): Rename to nametab for clarity.
(dirwatcher_pattern_match): New function.
(watch_subdirs): Ignore subdirs that don't match file name
pattern.
(dirwatcher_destroy): Exit immediately if no more watchers
are left.
|
|
|
|
* src/Makefile.am (AM_CPPFLAGS): Define INCLUDE_PATH_ARGS
* src/cmdline.opt: New option --include-directory (-I).
(help_hook): Print the actual content of the include search path.
* src/config.c (config_finish): Remove.
(config_init): New function. Set up include search path.
(config_parse): New function.
* src/direvent.c (main): Call config_init and config_parse.
* src/direvent.h (config_finish): Remove.
(config_init,config_parse): New proto.
* grecs: Upgrade.
* NEWS: Document changes.
* README: Document the --with-include-path option.
* configure.ac: New option --with-include-path.
* doc/direvent.8: Document the -I option and include search paths.
* doc/direvent.conf.5: Document include search paths.
* doc/direvent.texi: Document the -I option and include search paths.
|
|
* src/config.c (cb_option): New option 'shell'.
* src/direvent.h (HF_SHELL): New flag.
* src/progman.c (runcmd): Optionally run program via /bin/sh
* NEWS: Mention new option.
* doc/direvent.conf.5: Document the 'shell' option.
* grecs: Update.
* tests/shell.at: New test case.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Add new test.
|
|
* src/direvent.h (dirwatcher)<handler_tail>: New member.
* src/config.c (eventconf_flush): Use handler_tail to update
the handler list.
Remove erroneous check.
|
|
* .gitignore: Add am
* bootstrap: Create am, unless exists.
* Makefile.am (SUBDIRS): Add po
* acinclude.m4: New file.
* configure.ac: Use gettext
* doc/direvent.texi: Update
* po/.gitignore: New file
* po/POTFILES.in: New file.
* po/Makevars: New file.
* src/Makefile.am (LDADD): Add @LIBINTL@
(noinst_HEADERS): Add gettext.h
* src/config.c: gettextize
* src/direvent.c: Likewise.
* src/environ.c: Likewise.
* src/hashtab.c: Likewise.
* src/progman.c: Likewise.
* src/watcher.c: Likewise.
* src/gettext.h: New file.
* src/direvent.h: Add missing prototypes.
* tests/re05.at: Remove superfluous quoting.
|
|
Get rid of the kludgy waitpid; use the built-in self-test mode instead.
* src/cmdline.opt: New option --self-test.
* src/direvent.c (self_test_prog,self_test_pid)
(exit_code): New globals.
(self_test): New function.
(main): Call self_test if required.
If stop is set, break the loop immediately.
Return exit_code.
* src/direvent.h (stop,self_test_pid,exit_code): New externs.
* src/environ.c (environ_setup): Always define DIREVENT_SELF_TEST_PID
when in self-test mode.
* src/progman.c (process_cleanup): Special handling for termination of
the self-test script.
(runcmd): Define self_test_pid envvar in self-test mode.
* tests/Makefile.am: Remove waitpid.
* tests/waitfile.c: Removed.
* tests/printname: Send HUP to the self-test PID if sentinel file is created.
* tests/envdump.c (read_pid_and_sig): Restore arg to its pristine state
before exiting.
* tests/testsuite.at (AT_DIREVENT_TEST): New macro.
* tests/attrib.at: Rewrite using AT_DIREVENT_TEST.
* tests/cmdexp.at: Likewise.
* tests/create.at: Likewise.
* tests/createrec.at: Likewise.
* tests/delete.at: Likewise.
* tests/env00.at: Likewise.
* tests/env01.at: Likewise.
* tests/env02.at: Likewise.
* tests/env03.at: Likewise.
* tests/glob01.at: Likewise.
* tests/glob02.at: Likewise.
* tests/re01.at: Likewise.
* tests/re02.at: Likewise.
* tests/re03.at: Likewise.
* tests/re04.at: Likewise.
* tests/re05.at: Likewise.
* tests/write.at: Likewise.
* grecs (untracked content)
|
|
|