[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] consequence: spawn
- To: herbstluftwm _minus_ devel _at_ lists _dot_ sourceforge _dot_ net
- Subject: [PATCH] consequence: spawn
- From: Tyler Thomas Hart <tylerthomashart _at_ gmail _dot_ com>
- Date: Wed, 12 Dec 2012 18:19:42 -0800
Hi gang,
Since consequences are specified 'NAME'='VALUE', the command 'VALUE' is stored as a char*. There were two approaches to convert this into an exec-capable array. I included both patches, because I wasn't sure which one was ideal. Renammed to avoid ambiguity.
One approach was to pass the string as a '-c' argument to /bin/sh using fork() and execl(). This is less code, but I don't know if /bin/sh is depended anywhere else in the source (although Im pretty sure 99.9999% of users are using a POSIX shell).
The other approach was to parse the string using wordexp.h. Afaik this is a c standard lib, so I find it more elegant. But it pulls in more code. Converts the string to an array then fork()s and execvp()'s with this array.
Afaik, there are no side-effects to the wm when using this consequence. But I may have missed something in how the rule structs and routines work. Let me know if I missed anything.
Also, let me know if there is a better approach then the two above.
Thanks!
Tylo
Attachment:
cons_spawn_sh.patch
Description: Binary data
Attachment:
cons_spawn_wordexp.patch
Description: Binary data