Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 19/11/2010, à 08:56

PauseKawa

Comment savoir si un fichier est ouvert par une application ?

Bonjour,

Est il possible de savoir si un fichier est en cours d'utilisation par une application ?
Je ne recherche pas l'application mais juste à savoir si un fichier est en cours d'utilisation (même non locked) avant de l'ouvrir.
J'ai regarder du coté de /proc, lsof, inodes etc... mais je n'ai rien trouver de concret sur le sujet.

Merci d'avance


L'informatique c'est écologique. Un exemple : Je commande sur internet le dernier calendrier Pirelli. Résultat ? J'ai économisé mes pneus, mon essence, et je n'ai pas émis de gaz si néfaste pour notre planète. Et de toute manière, le facteur serait quand même passé pour m'amener mes factures.

Hors ligne

#2 Le 19/11/2010, à 09:12

jrev

Re : Comment savoir si un fichier est ouvert par une application ?

Si tu ne peux pas l'ouvrir c'est qu' a priori il est déjà ouvert.


Mal nommer les choses, c'est ajouter au malheur du monde

Hors ligne

#3 Le 19/11/2010, à 09:33

sosroot

Re : Comment savoir si un fichier est ouvert par une application ?

ton application tourne avec un ou des processus. Chaque processus possède un numéro.

Pour connaitre le numéro du processus qui utilise un fichier :

fuser "nom de ton fichier"

pour connaitre le processus qui tourne avec le numéro:

ps -edf|grep "numéro"

Ubuntu karmica - XP
Netgear WG111V3 - Radeon 9000 Family - AMD ATHLON XP2200+

Hors ligne

#4 Le 19/11/2010, à 10:59

jrev

Re : Comment savoir si un fichier est ouvert par une application ?

si je tape 

fuser nom_de_mon_image

ouverte dans Firefox je n'ai aucune réponse

Dernière modification par jrev (Le 19/11/2010, à 11:00)


Mal nommer les choses, c'est ajouter au malheur du monde

Hors ligne

#5 Le 19/11/2010, à 11:15

sosroot

Re : Comment savoir si un fichier est ouvert par une application ?

Fichier ouvert par une application veut dire en cours d'utilisation ou de modification par l'application genre un fichier de log dans lequel un processus écrit.


Ubuntu karmica - XP
Netgear WG111V3 - Radeon 9000 Family - AMD ATHLON XP2200+

Hors ligne

#6 Le 19/11/2010, à 11:25

Totor

Re : Comment savoir si un fichier est ouvert par une application ?

pourtant, lsof est fait pour ça hmm

lsof <nomfichier> &>/dev/null && echo "fichier utilisé" || echo "fichier non utilisé ou inexistant"

-- Lucid Lynx --

Hors ligne

#7 Le 19/11/2010, à 20:00

PauseKawa

Re : Comment savoir si un fichier est ouvert par une application ?

Bonsoir,

Et bien en fait cela n'est pas si évident et j'ai déjà tester cela.

patrice@Zeus:~/Bureau$ touch test.txt
patrice@Zeus:~/Bureau$ gedit test.txt
patrice@Zeus:~/Bureau$ lsof test.txt &>/dev/null && echo "fichier utilisé" || echo "fichier non utilisé ou inexistant"
fichier non utilisé ou inexistant
patrice@Zeus:~/Bureau$ fuser test.txt
patrice@Zeus:~/Bureau$

A la limite avec vi cela donne quelque chose

patrice@Zeus:/tmp$ touch /tmp/monfichier
patrice@Zeus:/tmp$ vi /tmp/monfichier
patrice@Zeus:~/Bureau$ sudo ls -Al /proc/*/fd | grep monfichier
[sudo] password for patrice: 
lrwx------ 1 patrice patrice 64 2010-11-19 18:58 4 -> /tmp/.monfichier.swp

Mais ce n'est que pour vi...

Une idée ?

Merci d'avance


L'informatique c'est écologique. Un exemple : Je commande sur internet le dernier calendrier Pirelli. Résultat ? J'ai économisé mes pneus, mon essence, et je n'ai pas émis de gaz si néfaste pour notre planète. Et de toute manière, le facteur serait quand même passé pour m'amener mes factures.

Hors ligne

#8 Le 19/11/2010, à 20:10

PauseKawa

Re : Comment savoir si un fichier est ouvert par une application ?

Re,

Petit rêve fou : Existe t'il quelque pars une liste des inodes utilisés, ou plutôt en cours d'utilisation ?
Dans ce cas je n'ai qu'a récupérer l'inode avec un stat par exemple et de regarder dans cette 'hypothétique' liste.


L'informatique c'est écologique. Un exemple : Je commande sur internet le dernier calendrier Pirelli. Résultat ? J'ai économisé mes pneus, mon essence, et je n'ai pas émis de gaz si néfaste pour notre planète. Et de toute manière, le facteur serait quand même passé pour m'amener mes factures.

Hors ligne

#9 Le 19/11/2010, à 20:10

kyncani

Re : Comment savoir si un fichier est ouvert par une application ?

Ce doit, je suppose, être parce que vim comme gedit ne conservent pas le fichier ouvert.
Ils doivent l'ouvrir au début pour le lire entièrement ou le copier et le fermer tout de suite après.
Tout le travail doit se faire en mémoire ou dans un fichier temporaire (le .swp de vim).
A l'enregistrement du fichier seulement ils doivent l'ouvrir à nouveau pour écrire son contenu.

Du coup je ne vois pas vraiment comment savoir si un fichier est ouvert, sauf à prendre en compte tous les cas de figure (lsof pour les redirections, le .swp pour vim, et des tests propres à chaque application).

Edit: pour la liste des inodes utilisées, tu peux utiliser lsof ou aller voir dans ls -l /proc/*/fd/

Dernière modification par kyncani (Le 19/11/2010, à 20:11)

Hors ligne

#10 Le 19/11/2010, à 20:13

PauseKawa

Re : Comment savoir si un fichier est ouvert par une application ?

C'est bien ce que je pense... Mais j'ai confiance wink
Au départ j'avais penser utiliser stat mais cela ne me dit pas si le fichier est encore ouvert...


L'informatique c'est écologique. Un exemple : Je commande sur internet le dernier calendrier Pirelli. Résultat ? J'ai économisé mes pneus, mon essence, et je n'ai pas émis de gaz si néfaste pour notre planète. Et de toute manière, le facteur serait quand même passé pour m'amener mes factures.

Hors ligne

#11 Le 19/11/2010, à 21:06

Totor

Re : Comment savoir si un fichier est ouvert par une application ?

gedit ne fait que charger le fichier en mémoire. Une fois chargé, le fichier est effectivement fermé.


-- Lucid Lynx --

Hors ligne

#12 Le 20/11/2010, à 02:32

ehmicky

Re : Comment savoir si un fichier est ouvert par une application ?

Je pense pas que ce soit la meilleure solution (lsof est là pour ça...), et c'est un peu lourd et maladroit mais ça :

ls -l /proc/*/fd/* 2> /dev/null\
    | awk '{ print $10 }'\
    | sort\
    | uniq\
    | sed '/\(^socket\)\|\(^pipe\)\|\(^\/dev\/\)/ d'

Imprime la liste des fichiers ouverts (j'ai enlevé les sockets, les pipes et les fichiers dans /dev/).

Edit : lsof ne marche pas non plus avec moi sur les fichiers ouverts par gedit. C'est peut-être parcequ'il passe par un buffer ou fichier temporaire et n'accède au fichier que lors d'une sauvegarde ou de l'ouverture du fichier ? (du coup le fichier n'est pas ouvert sinon)
Edit 2 : pour repartir sur mon mauvais exemple,

for i in /proc/*/fd/* ; do readlink -f "$i" ; done 2> /dev/null

est plus sûr mais bien plus long.

Dernière modification par ehmicky (Le 20/11/2010, à 02:45)


Stego++, bibliothèque libre de stéganographie (avec cryptographie), à venir !
Besoin de votre aide :
Stats sur les compilateurs C++ les plus utilisés
Comment utiliser les archetypes C++ ?

Hors ligne

#13 Le 20/11/2010, à 11:17

Totor

Re : Comment savoir si un fichier est ouvert par une application ?

ben flûte alors...

man lsof a écrit :

LSOF(8)                                                                                                                                                                LSOF(8)

NAME
       lsof - list open files
[...]

pour ceux qui comprennent l'anglais, je pense que c'est assez explicite ...

Par ailleurs; la liste se trouvant dans /proc n'est pas exhaustive :

$ gedit &
[1] 2255

$ ls -l /proc/2255/fd/*
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/0 -> /dev/pts/0
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/1 -> /dev/pts/0
l-wx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/10 -> pipe:[14665]
lr-x------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/11 -> pipe:[14666]
l-wx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/12 -> pipe:[14666]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/13 -> socket:[14667]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/14 -> socket:[14669]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/15 -> socket:[14672]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/16 -> socket:[14673]
lr-x------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/17 -> inotify
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/18 -> socket:[14675]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/2 -> /dev/pts/0
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/3 -> socket:[14654]
lr-x------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/4 -> pipe:[14657]
l-wx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/5 -> pipe:[14657]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/6 -> socket:[14658]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/7 -> socket:[14660]
lrwx------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/8 -> socket:[14662]
lr-x------ 1 Totor users 64 2010-11-20 10:09 /proc/2255/fd/9 -> pipe:[14665]

$ lsof -p 2255
COMMAND  PID   USER   FD   TYPE             DEVICE SIZE/OFF    NODE NAME
gedit   2255 Totor  cwd    DIR                8,3    20480    2271 /home/Totor
gedit   2255 Totor  rtd    DIR                8,2     4096       2 /
gedit   2255 Totor  txt    REG                8,2   688064 1051034 /usr/bin/gedit
gedit   2255 Totor  mem    REG                8,2   136032  661885 /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf
gedit   2255 Totor  DEL    REG                0,4          3276816 /SYSV00000000
gedit   2255 Totor  DEL    REG                0,4          3244047 /SYSV00000000
gedit   2255 Totor  mem    REG                8,2    70912 1062873 /lib/libbz2.so.1.0.4
gedit   2255 Totor  mem    REG                8,2   232104 1051982 /usr/lib/libcroco-0.6.so.3.0.1
gedit   2255 Totor  mem    REG                8,2   251608 1052244 /usr/lib/libgsf-1.so.114.0.16
gedit   2255 Totor  mem    REG                8,2   225792 1055439 /usr/lib/librsvg-2.so.2.26.3
gedit   2255 Totor  mem    REG                8,2    10496 1055424 /usr/lib/gtk-2.0/2.10.0/loaders/svg_loader.so
gedit   2255 Totor  mem    REG                8,2   139640  661920 /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf
gedit   2255 Totor  mem    REG                8,2   740296 1051885 /usr/lib/libaspell.so.15.1.4
gedit   2255 Totor  mem    REG                8,2    10432 1053978 /usr/lib/enchant/libenchant_aspell.so
gedit   2255 Totor  mem    REG                8,2    51712 1053980 /usr/lib/enchant/libenchant_ispell.so
gedit   2255 Totor  mem    REG                8,2    55368 1053979 /usr/lib/enchant/libenchant_hspell.so
gedit   2255 Totor  mem    REG                8,2    92552 1044564 /lib/libgcc_s.so.1
gedit   2255 Totor  mem    REG                8,2  1044112 1052708 /usr/lib/libstdc++.so.6.0.13
gedit   2255 Totor  mem    REG                8,2   261880 1052355 /usr/lib/libhunspell-1.2.so.0.0.0
gedit   2255 Totor  mem    REG                8,2    22976 1053981 /usr/lib/enchant/libenchant_myspell.so
gedit   2255 Totor  mem    REG                8,2    10416 1053424 /usr/lib/gtk-2.0/2.10.0/immodules/im-cedilla.so
gedit   2255 Totor  mem    REG                8,2    18928 1051048 /usr/lib/gedit-2/plugins/libdocinfo.so
gedit   2255 Totor  mem    REG                8,2    19056 1051051 /usr/lib/gedit-2/plugins/libsort.so
gedit   2255 Totor  mem    REG                8,2    27200 1051050 /usr/lib/gedit-2/plugins/libmodelines.so
gedit   2255 Totor  mem    REG                8,2    31632 1052306 /usr/lib/gedit-2/plugins/libtime.so
gedit   2255 Totor  mem    REG                8,2    43552 1052069 /usr/lib/libenchant.so.1.6.0
gedit   2255 Totor  mem    REG                8,2    86032 1051052 /usr/lib/gedit-2/plugins/libspell.so
gedit   2255 Totor  mem    REG                8,2   321524 1089205 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf
gedit   2255 Totor  mem    REG                8,2    18792 1051474 /usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-ico.so
gedit   2255 Totor  mem    REG                8,2    85224 1055411 /usr/lib/gio/modules/libgioremote-volume-monitor.so
gedit   2255 Totor  mem    REG                8,2    23152 1053414 /usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-png.so
gedit   2255 Totor  mem    REG                8,2   169624 1051049 /usr/lib/gedit-2/plugins/libfilebrowser.so
gedit   2255 Totor  mem    REG                8,2    10648 1054043 /lib/libutil-2.11.1.so
gedit   2255 Totor  mem    REG                8,2  1622304 1049216 /lib/libcrypto.so.0.9.8
gedit   2255 Totor  mem    REG                8,2   333856 1049249 /lib/libssl.so.0.9.8
gedit   2255 Totor  mem    REG                8,2  2762488 1052632 /usr/lib/libpython2.6.so.1.0
gedit   2255 Totor  mem    REG                8,2   109616 1055063 /usr/lib/gedit-2/plugin-loaders/libpythonloader.so
gedit   2255 Totor  mem    REG                8,2    10376 1055062 /usr/lib/gedit-2/plugin-loaders/libcloader.so
gedit   2255 Totor  mem    REG                8,2   622280 1089203 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
gedit   2255 Totor  mem    REG                8,2    10936 1060637 /usr/lib/pango/1.6.0/modules/pango-basic-fc.so
gedit   2255 Totor  mem    REG                8,2   200092 1089218 /usr/share/fonts/truetype/ttf-indic-fonts-core/Vemana.ttf
gedit   2255 Totor  mem    REG                8,2    15112 1206298 /var/cache/fontconfig/5e10083637a12ecd1bff191eb66bfa2f-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1472 1206297 /var/cache/fontconfig/c05880de57d1f5e948fdfacc138775d9-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    15504 1199967 /var/cache/fontconfig/603b2eb47209ddb3c5269b217a306167-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    34040 1206296 /var/cache/fontconfig/945677eb7aeaf62f1d50efc3fb3ec7d8-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     7224 1206294 /var/cache/fontconfig/99e8ed0e538f840c565b6ed5dad60d56-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    11328 1206293 /var/cache/fontconfig/e383d7ea5fbe662a33d9b44caf393297-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    14120 1206503 /var/cache/fontconfig/a46337af8a0b4c9b317ad981ec3bdf87-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1408 1206405 /var/cache/fontconfig/79b7902a698c37d747b157374a08587f-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1832 1206290 /var/cache/fontconfig/6edd069ccec3ba28096b368c434fa861-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     5480 1206259 /var/cache/fontconfig/e3fa16a14183b06aa45b3e009278fd14-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     2944 1206258 /var/cache/fontconfig/e7071f4a29fa870f4323321c154eba04-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    17952 1206256 /var/cache/fontconfig/926e794c3d5e5dffcaf2fa83ef8d36c2-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    14864 1206255 /var/cache/fontconfig/6eb3985aa4124903f6ff08ba781cd364-le64.cache-3
gedit   2255 Totor  mem    REG                8,2   165808 1206253 /var/cache/fontconfig/4ca92cf76c0cf3dfa7f011127eff595d-le64.cache-3
gedit   2255 Totor  mem    REG                8,2   179176 1206251 /var/cache/fontconfig/6abf76b0b4cc7192703d8431ac929b75-le64.cache-3
gedit   2255 Totor  mem    REG                8,2   184576 1206250 /var/cache/fontconfig/f408d08d2fce062ab660f628db78bf96-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1640 1206249 /var/cache/fontconfig/4c73fe0c47614734b17d736dbde7580a-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     2984 1206248 /var/cache/fontconfig/0d8c3b2ac0904cb8a57a757ad11a4a08-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1600 1206247 /var/cache/fontconfig/6a53c69dea097a2d716e069445527da8-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    22520 1206246 /var/cache/fontconfig/a755afe4a08bf5b97852ceb7400b47bc-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    10344 1206245 /var/cache/fontconfig/f680583fed5bdc90d95a16af47e16528-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1584 1206244 /var/cache/fontconfig/a8d35ba226d862df35f7c320f882e11a-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    12912 1206243 /var/cache/fontconfig/6d41288fd70b0be22e8c3a91e032eec0-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    13248 1206242 /var/cache/fontconfig/24cfa87181cfa5a1c0a5ecfd4c14c4b3-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     5984 1206241 /var/cache/fontconfig/4609d6ed693fb2a61c04ed6a1f4c071e-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    45384 1206240 /var/cache/fontconfig/e3de0de479f42330eadf588a55fb5bf4-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    31352 1199836 /var/cache/fontconfig/a6354e3ac43af67bd8d7b8e43c34e49f-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    63840 1206239 /var/cache/fontconfig/0f34bcd4b6ee430af32735b75db7f02b-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    12160 1205706 /var/cache/fontconfig/d60319d88cac85ba9e1a07bd06cfbb8c-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     2736 1206232 /var/cache/fontconfig/9451a55048e8dbe8633e64d34165fdf2-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     2080 1206231 /var/cache/fontconfig/4794a0821666d79190d59a36cb4f44b5-le64.cache-3
gedit   2255 Totor  mem    REG                8,2   186864 1206230 /var/cache/fontconfig/365b55f210c0a22e9a19e35191240f32-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    37184 1206229 /var/cache/fontconfig/d52a8644073d54c13679302ca1180695-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    24416 1206228 /var/cache/fontconfig/105b9c7e6f0a4f82d8c9b6e39c52c6f9-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    13720 1206128 /var/cache/fontconfig/089dead882dea3570ffc31a9898cfb69-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    12856 1202128 /var/cache/fontconfig/fac9d1061ce4dddb2143955f84876fd7-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    32808 1189770 /var/cache/fontconfig/cabbd14511b9e8a55e92af97fb3a0461-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    41880 1205782 /var/cache/fontconfig/e13b20fdb08344e0e664864cc2ede53d-le64.cache-3
gedit   2255 Totor  mem    REG                8,2    47048 1044630 /lib/libudev.so.0.6.1
gedit   2255 Totor  mem    REG                8,2   102872 1055369 /usr/lib/libgvfscommon.so.0.0.0
gedit   2255 Totor  mem    REG                8,2    16728 1202132 /var/cache/fontconfig/7ef2298fde41cc6eeb7af42e48b7d293-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     1298   56975 /usr/share/locale-langpack/fr/LC_MESSAGES/launchpad-integration.mo
gedit   2255 Totor  mem    REG                8,2   106488 1045011 /usr/share/mime/mime.cache
gedit   2255 Totor  mem    REG                8,2   177136 1055412 /usr/lib/gio/modules/libgvfsdbus.so
gedit   2255 Totor  mem    REG                8,2  5717452 1192990 /usr/share/icons/hicolor/icon-theme.cache
gedit   2255 Totor  mem    REG                8,2  7261812 1191099 /usr/share/icons/gnome/icon-theme.cache
gedit   2255 Totor  mem    REG                8,2    43512 1051447 /usr/lib/gtk-2.0/2.10.0/engines/libpixmap.so
gedit   2255 Totor  mem    REG                8,2    60464 1056089 /usr/lib/gtk-2.0/2.10.0/engines/libindustrial.so
gedit   2255 Totor  mem    REG                8,2    39248 1052444 /usr/lib/libltdl.so.7.2.1
gedit   2255 Totor  mem    REG                8,2    59872 1052717 /usr/lib/libtdb.so.1.2.0
gedit   2255 Totor  mem    REG                8,2    26840 1052527 /usr/lib/libogg.so.0.6.0
gedit   2255 Totor  mem    REG                8,2   182584 1052768 /usr/lib/libvorbis.so.0.4.3
gedit   2255 Totor  mem    REG                8,2    31080 1052772 /usr/lib/libvorbisfile.so.3.3.2
gedit   2255 Totor  mem    REG                8,2    64080 1051946 /usr/lib/libcanberra.so.0.2.1
gedit   2255 Totor  mem    REG                8,2    18848 1051944 /usr/lib/libcanberra-gtk.so.0.1.5
gedit   2255 Totor  mem    REG                8,2     1400 1205794 /var/cache/fontconfig/2da08ab1328900a4581f87e74c0172ce-le64.cache-3
gedit   2255 Totor  mem    REG                8,2   131994   57014 /usr/share/locale-langpack/fr/LC_MESSAGES/libc.mo
gedit   2255 Totor  mem    REG                8,2    23112 1056138 /usr/lib/gtk-2.0/modules/libcanberra-gtk-module.so
gedit   2255 Totor  mem    REG                8,2    51712 1054050 /lib/libnss_files-2.11.1.so
gedit   2255 Totor  mem    REG                8,2    43552 1051591 /lib/libnss_nis-2.11.1.so
gedit   2255 Totor  mem    REG                8,2    97256 1051459 /lib/libnsl-2.11.1.so
gedit   2255 Totor  mem    REG                8,2    35712 1051518 /lib/libnss_compat-2.11.1.so
gedit   2255 Totor  mem    REG                8,2    22560 1051814 /usr/lib/libXdmcp.so.6.0.0
gedit   2255 Totor  mem    REG                8,2    14488 1051803 /usr/lib/libXau.so.6.0.0
gedit   2255 Totor  mem    REG                8,2   165960 1044557 /lib/libexpat.so.1.5.2
gedit   2255 Totor  mem    REG                8,2    19008 1044672 /lib/libuuid.so.1.3.0
gedit   2255 Totor  mem    REG                8,2   113072 1052809 /usr/lib/libxcb.so.1.1.0
gedit   2255 Totor  mem    REG                8,2    34888 1052807 /usr/lib/libxcb-render.so.0.0.0
gedit   2255 Totor  mem    REG                8,2    14536 1052805 /usr/lib/libxcb-render-util.so.0.0.0
gedit   2255 Totor  mem    REG                8,2   158736 1048619 /lib/libpng12.so.0.42.0
gedit   2255 Totor  mem    REG                8,2    98000 1052030 /usr/lib/libdirect-1.2.so.0.8.0
gedit   2255 Totor  mem    REG                8,2    39448 1052107 /usr/lib/libfusion-1.2.so.0.8.0
gedit   2255 Totor  mem    REG                8,2   533800 1052032 /usr/lib/libdirectfb-1.2.so.0.8.0
gedit   2255 Totor  mem    REG                8,2   362664 1052574 /usr/lib/libpixman-1.so.0.16.4
gedit   2255 Totor  mem    REG                8,2   117592 1044646 /lib/libselinux.so.1
gedit   2255 Totor  mem    REG                8,2    93000 1051500 /lib/libresolv-2.11.1.so
gedit   2255 Totor  mem    REG                8,2   186440 1044622 /lib/libpcre.so.3.12.1
gedit   2255 Totor  mem    REG                8,2    14696 1054051 /lib/libdl-2.11.1.so
gedit   2255 Totor  mem    REG                8,2   216832 1052095 /usr/lib/libfontconfig.so.1.4.4
gedit   2255 Totor  mem    REG                8,2    92752 1044679 /lib/libz.so.1.2.3.3
gedit   2255 Totor  mem    REG                8,2   547112 1045234 /usr/lib/libfreetype.so.6.3.22
gedit   2255 Totor  mem    REG                8,2   172128 1052548 /usr/lib/libpangoft2-1.0.so.0.2800.0
gedit   2255 Totor  mem    REG                8,2    22568 1051818 /usr/lib/libXfixes.so.3.1.0
gedit   2255 Totor  mem    REG                8,2    10272 1051812 /usr/lib/libXdamage.so.1.1.0
gedit   2255 Totor  mem    REG                8,2    10256 1051808 /usr/lib/libXcomposite.so.1.0.0
gedit   2255 Totor  mem    REG                8,2    39232 1051810 /usr/lib/libXcursor.so.1.0.2
gedit   2255 Totor  mem    REG                8,2    34984 1051836 /usr/lib/libXrandr.so.2.2.0
gedit   2255 Totor  mem    REG                8,2    63864 1051824 /usr/lib/libXi.so.6.1.0
gedit   2255 Totor  mem    REG                8,2    10496 1051826 /usr/lib/libXinerama.so.1.0.0
gedit   2255 Totor  mem    REG                8,2    39400 1051838 /usr/lib/libXrender.so.1.3.0
gedit   2255 Totor  mem    REG                8,2    73600 1051816 /usr/lib/libXext.so.6.4.0
gedit   2255 Totor  mem    REG                8,2    31744 1051498 /lib/librt-2.11.1.so
gedit   2255 Totor  mem    REG                8,2   256768 1044542 /lib/libdbus-1.so.3.4.0
gedit   2255 Totor  mem    REG                8,2   139528 1052014 /usr/lib/libdbus-glib-1.so.2.1.0
gedit   2255 Totor  mem    REG                8,2   450072 1051789 /usr/lib/libORBit-2.so.0.1.0
gedit   2255 Totor  mem    REG                8,2  1372312 1060104 /usr/lib/libxml2.so.2.7.6
gedit   2255 Totor  mem    REG                8,2    52400 1052546 /usr/lib/libpangocairo-1.0.so.0.2800.0
gedit   2255 Totor  mem    REG                8,2    97904 1051768 /usr/lib/libICE.so.6.3.0
gedit   2255 Totor  mem    REG                8,2  1572232 1054047 /lib/libc-2.11.1.so
gedit   2255 Totor  mem    REG                8,2   135745 1054045 /lib/libpthread-2.11.1.so
gedit   2255 Totor  mem    REG                8,2   534832 1048709 /lib/libm-2.11.1.so
gedit   2255 Totor  mem    REG                8,2    35032 1051797 /usr/lib/libSM.so.6.0.1
gedit   2255 Totor  mem    REG                8,2  1269216 1051799 /usr/lib/libX11.so.6.3.0
gedit   2255 Totor  mem    REG                8,2   905480 1068422 /lib/libglib-2.0.so.0.2400.1
gedit   2255 Totor  mem    REG                8,2    18888 1068425 /usr/lib/libgthread-2.0.so.0.2400.1
gedit   2255 Totor  mem    REG                8,2    14536 1068424 /usr/lib/libgmodule-2.0.so.0.2400.1
gedit   2255 Totor  mem    REG                8,2   290184 1068423 /usr/lib/libgobject-2.0.so.0.2400.1
gedit   2255 Totor  mem    REG                8,2   302536 1052544 /usr/lib/libpango-1.0.so.0.2800.0
gedit   2255 Totor  mem    REG                8,2   532792 1051936 /usr/lib/libcairo.so.2.10800.10
gedit   2255 Totor  mem    REG                8,2   113648 1053442 /usr/lib/libgdk_pixbuf-2.0.so.0.2000.1
gedit   2255 Totor  mem    REG                8,2   727136 1068813 /usr/lib/libgio-2.0.so.0.2400.1
gedit   2255 Totor  mem    REG                8,2   133912 1048591 /usr/lib/libatk-1.0.so.0.3009.1
gedit   2255 Totor  mem    REG                8,2   707760 1053441 /usr/lib/libgdk-x11-2.0.so.0.2000.1
gedit   2255 Totor  mem    REG                8,2  4325736 1053440 /usr/lib/libgtk-x11-2.0.so.0.2000.1
gedit   2255 Totor  mem    REG                8,2    14824 1052424 /usr/lib/liblaunchpad-integration.so.1.0.0
gedit   2255 Totor  mem    REG                8,2   248088 1052120 /usr/lib/libgconf-2.so.4.1.5
gedit   2255 Totor  mem    REG                8,2   430984 1054997 /usr/lib/libgtksourceview-2.0.so.0.0.0
gedit   2255 Totor  mem    REG                8,2   136936 1051470 /lib/ld-2.11.1.so
gedit   2255 Totor  mem    REG                8,2     5896 1200762 /var/cache/fontconfig/1e6452c76031a6c0db6bc08e85cdd45a-le64.cache-3
gedit   2255 Totor  mem    REG                8,2     8726   49448 /usr/share/locale-langpack/fr/LC_MESSAGES/atk10.mo
gedit   2255 Totor  mem    REG                8,2    34370   52274 /usr/share/locale-langpack/fr/LC_MESSAGES/gtksourceview.mo
gedit   2255 Totor  mem    REG                8,2   171924   52251 /usr/share/locale-langpack/fr/LC_MESSAGES/gtk20-properties.mo
gedit   2255 Totor  mem    REG                8,2    81895   52309 /usr/share/locale-langpack/fr/LC_MESSAGES/gtk20.mo
gedit   2255 Totor  mem    REG                8,2    98664   49471 /usr/share/locale-langpack/fr/LC_MESSAGES/gedit.mo
gedit   2255 Totor  mem    REG                8,2   256324 1056903 /usr/lib/locale/fr_FR.utf8/LC_CTYPE
gedit   2255 Totor  mem    REG                8,2  1170770 1056759 /usr/lib/locale/fr_FR.utf8/LC_COLLATE
gedit   2255 Totor  mem    REG                8,2    14960 1206300 /var/cache/fontconfig/ba022efc551c75e21c690774bbcf5304-le64.cache-3
gedit   2255 Totor  mem    REG                8,3     1912    9716 /home/Totor/.local/share/mime/mime.cache
gedit   2255 Totor  mem    REG                8,2    48597   52304 /usr/share/locale-langpack/fr/LC_MESSAGES/glib20.mo
gedit   2255 Totor  mem    REG                8,2       54   49604 /usr/lib/locale/fr_FR.utf8/LC_NUMERIC
gedit   2255 Totor  mem    REG                8,2     2502   49605 /usr/lib/locale/fr_FR.utf8/LC_TIME
gedit   2255 Totor  mem    REG                8,2      290   49606 /usr/lib/locale/fr_FR.utf8/LC_MONETARY
gedit   2255 Totor  mem    REG                8,2       54   49608 /usr/lib/locale/fr_FR.utf8/LC_MESSAGES/SYS_LC_MESSAGES
gedit   2255 Totor  mem    REG                8,2       34 1056909 /usr/lib/locale/fr_FR.utf8/LC_PAPER
gedit   2255 Totor  mem    REG                8,2       71   49609 /usr/lib/locale/fr_FR.utf8/LC_NAME
gedit   2255 Totor  mem    REG                8,2      153   49610 /usr/lib/locale/fr_FR.utf8/LC_ADDRESS
gedit   2255 Totor  mem    REG                8,2       56   49611 /usr/lib/locale/fr_FR.utf8/LC_TELEPHONE
gedit   2255 Totor  mem    REG                8,2       23 1056905 /usr/lib/locale/fr_FR.utf8/LC_MEASUREMENT
gedit   2255 Totor  mem    REG                8,2    26048 1054191 /usr/lib/gconv/gconv-modules.cache
gedit   2255 Totor  mem    REG                8,2      311   49612 /usr/lib/locale/fr_FR.utf8/LC_IDENTIFICATION
gedit   2255 Totor    0u   CHR              136,0      0t0       3 /dev/pts/0
gedit   2255 Totor    1u   CHR              136,0      0t0       3 /dev/pts/0
gedit   2255 Totor    2u   CHR              136,0      0t0       3 /dev/pts/0
gedit   2255 Totor    3u  unix 0xffff8801703e7000      0t0   14654 socket
gedit   2255 Totor    4r  FIFO                0,8      0t0   14657 pipe
gedit   2255 Totor    5w  FIFO                0,8      0t0   14657 pipe
gedit   2255 Totor    6u  unix 0xffff88017bc76d00      0t0   14658 socket
gedit   2255 Totor    7u  unix 0xffff8801834ca400      0t0   14660 /tmp/gedit.Totor.2561896284
gedit   2255 Totor    8u  unix 0xffff8801703e7600      0t0   14662 socket
gedit   2255 Totor    9r  FIFO                0,8      0t0   14665 pipe
gedit   2255 Totor   10w  FIFO                0,8      0t0   14665 pipe
gedit   2255 Totor   11r  FIFO                0,8      0t0   14666 pipe
gedit   2255 Totor   12w  FIFO                0,8      0t0   14666 pipe
gedit   2255 Totor   13u  unix 0xffff8801703e7c00      0t0   14667 socket
gedit   2255 Totor   14u  unix 0xffff8801703e6d00      0t0   14669 /tmp/orbit-Totor/linc-8cf-0-7ee651ae524e5
gedit   2255 Totor   15u  unix 0xffff8801834c8900      0t0   14672 /tmp/orbit-Totor/linc-8cf-0-7ee651ae524e5
gedit   2255 Totor   16u  unix 0xffff8801703e6400      0t0   14673 socket
gedit   2255 Totor   17r   DIR               0,11        0       1 inotify
gedit   2255 Totor   18u  unix 0xffff88017bcd6400      0t0   14675 socket

-- Lucid Lynx --

Hors ligne

#14 Le 20/11/2010, à 12:59

PauseKawa

Re : Comment savoir si un fichier est ouvert par une application ?

Bonjour,

Totor a écrit :

ben flûte alors...

man lsof a écrit :

LSOF(8)                                                                                                                                                                LSOF(8)

NAME
       lsof - list open files
[...]

pour ceux qui comprennent l'anglais, je pense que c'est assez explicite ...

Je pense que tout le monde avais bien compris Totor.
Ce que je disais concerne le fichier proprement dit, sans savoir quel programme l'utilise et sans trace du fichier en question.
Je recherchais juste une idée pour les programmes qui travaillent avec une copie. Mais le fichier n'étant pas 'ouvert' pour le système pas de solution je pense.
Même si je mets un lock exclusif sur le fichier cela ne sert à rien puisque qu'il n'est pas ouvert.

La solution finale est donc : Si le fichier est ouvert directement c'est lsof, sinon pas de solution.


L'informatique c'est écologique. Un exemple : Je commande sur internet le dernier calendrier Pirelli. Résultat ? J'ai économisé mes pneus, mon essence, et je n'ai pas émis de gaz si néfaste pour notre planète. Et de toute manière, le facteur serait quand même passé pour m'amener mes factures.

Hors ligne

#15 Le 21/11/2010, à 10:31

PauseKawa

Re : Comment savoir si un fichier est ouvert par une application ?

Bonjour,

Suite à une autre discussion sur un autre forum une alternative : inotify et un wrapper.
Cela impose une surveillance du système mais c'est aussi une réponse pour ce qui est des éditeurs.

@+


L'informatique c'est écologique. Un exemple : Je commande sur internet le dernier calendrier Pirelli. Résultat ? J'ai économisé mes pneus, mon essence, et je n'ai pas émis de gaz si néfaste pour notre planète. Et de toute manière, le facteur serait quand même passé pour m'amener mes factures.

Hors ligne