On Thu, Jul 05, 2018 at 03:42:55PM +0200, Christian Brauner wrote: > On Wed, Jul 04, 2018 at 03:23:19PM -0400, Chaetoo3 wrote: > > Hi! > > > > I try to use the liblxc start() API from my process and it worked, but > > I notice it would not set the process name for the container process > > as it would do from the lxc-start command line. Instead the container > > process stayed with the name of my caller. > > You mean it wouldn't change from "my binary --with --args" to "[lxc monitor]? > > > > > I sniff around and make a local fix. I'm sorry I do not know how to > > contribute this to lxc, but if anyone want to do that, here is the > > code. Reason is: /proc/self/stat contains the process name in > > parentheses. If the name contains space, when liblxc parse the file > > it would get off by one field, and get confused and fail in > > setproctitle(). > > > > I don't know if my fix is robust enough for real, but at least should > > point someone to the right place? This looks for trailing ") " > > sequence (parent and space). That is still subject to errors because > > the process name might include such, but maybe there is not a way to > > avoid a false positive sometimes. You cannot paren match either, > > because a process may not have matching. Well anyway, this at least > > account for spaces in process name, which is a little bit common > > situation I think. > > > > I hope it would help someone. > > > > > > @@ -296,10 +296,23 @@ int setproctitle(char *title) > > return -1; > > } > > > > - /* Skip the first 25 fields, column 26-28 are start_code, end_code, > > + /* Find the end of the process name, which is bounded by > > parentheses. > > + * Some processes may include parens in their name, which in the > > worst > > + * case can trigger a false positive no matter what we do here. > > This > > + * tries to avoid that by looking for a ') ' sequence. > > + */ > > Interesting. Ccing Mr. Andersen in case he has any opinions or wants to > contribute a patch.
I suppose we could read /proc/self/status, find what's after the Name: field, and then skip that many characters? I probably won't have time to look at a patch this week, though. Tycho _______________________________________________ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users