Re: lua+pgrep
At 1245863677 time_t, Alex Cornejo wrote: The problem is that if we do os.execute(pgrep -f pyscript) from lua, it will always return a process, even if pyscript is not running. Actually, you can do os.execute(pgrep -f blablafoofoobar) and it will always find a process. Weird huh? Any ideas on why this is or how to fix it? No but this seems like a question for awesome mailing list, or even lua-l. :) Cheers, -- Julien Danjou // ᐰ jul...@danjou.info http://julien.danjou.info // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD // Tomorrow I was nothing, yesterday I'll be. signature.asc Description: Digital signature
Re: lua+pgrep
Yup, I actually pinned down the problem now, I think its a bug in pgrep. You instance pgrep -f someprogname and pgrep first queries the system for a list of processes with their respective command lines, then iterates over each process and searches for the substring someprogname inside each command line and returns the matches. The problem is that the process pgrep with commandline pgrep -f someprogname will show up in this list, and hence pgrep has to skip its own process ID while doing the iteration, or at least that what pgrep is supposed to do (according to the man page). When you do os.execute(pgrep -f someprogname) lua runs this inside the shell, so the commandline is actually sh -c pgrep -f someprogname and THIS is the key problem, since apparently pgrep does not skip its own process ID when it is executed in this way. This is my theory after playing around with pgrep -l -f someprogname, but I don't know if I should download pgrep's source code and try to fix it, or try to find a work around in the lua side of things. Any ideas? Namely I wanted to implement a startup module for awesome which has a list of programs you would like to run when awesome start, but only runs them if they are not already running (to avoid problems when restarting awesome for example). This is trivially implemented in bash, but I wanted to do it in lua. Cheers, Alex On Thu, Jun 25, 2009 at 3:48 AM, Julien Danjoujul...@danjou.info wrote: At 1245863677 time_t, Alex Cornejo wrote: The problem is that if we do os.execute(pgrep -f pyscript) from lua, it will always return a process, even if pyscript is not running. Actually, you can do os.execute(pgrep -f blablafoofoobar) and it will always find a process. Weird huh? Any ideas on why this is or how to fix it? No but this seems like a question for awesome mailing list, or even lua-l. :) Cheers, -- Julien Danjou // ᐰ jul...@danjou.info http://julien.danjou.info // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD // Tomorrow I was nothing, yesterday I'll be. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkpDK7QACgkQpGK1HsL+5c3NjwCgw3qQF6aBecrq4WOCNugzhu8K Pr8AoNDf4WHbAoS4U6/yZRkC4EuoHfxZ =n42G -END PGP SIGNATURE- -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.
Re: lua+pgrep
At 1245953624 time_t, Alex Cornejo wrote: Any ideas? Namely I wanted to implement a startup module for awesome which has a list of programs you would like to run when awesome start, but only runs them if they are not already running (to avoid problems when restarting awesome for example). This is trivially implemented in bash, but I wanted to do it in lua. os.execute(exec pgrep...) -- Julien Danjou // ᐰ jul...@danjou.info http://julien.danjou.info // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD // This is the end of my signature. signature.asc Description: Digital signature
Re: lua+pgrep
Don't use pgrep (ps and grep may have better results)? Write the programs you started to a file and delete them after awesome completes (like, after in the .xinitrc)? -- Andrei Thorp, Developer: Xandros Corp. (http://www.xandros.com) -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.
lua+pgrep
Hi ppl, Suppose you want to code something in lua that needs to check if xterm is running, a quick way to do that in bash would be pgrep xterm. However, sometimes you want to check for a program that use an interpreter. For example suppose you have a python script call pyscript, if you run pgrep pyscript that will fail to find pyscript even if its running, however pgrep -f pyscript will do the trick. The reason is that the command line for the script shows up in ps as python /usr/bin/pyscript as opposed to just /usr/bin/pyscript. The problem is that if we do os.execute(pgrep -f pyscript) from lua, it will always return a process, even if pyscript is not running. Actually, you can do os.execute(pgrep -f blablafoofoobar) and it will always find a process. Weird huh? Any ideas on why this is or how to fix it? Cheers, Alex -- To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.